fix fixunicode

This commit is contained in:
j 2014-11-11 12:00:22 +01:00
parent cd9f49b771
commit f5770f12d1

View file

@ -6,7 +6,7 @@ from __future__ import print_function
import unicodedata
from six import unichr
from six import unichr, PY3
__all__ = ['fix_bad_unicode']
@ -75,7 +75,7 @@ def fix_bad_unicode(text):
>>> fix_bad_unicode('This text was never Unicode at all\x85')
'This text was never Unicode at all…'
"""
if not isinstance(text, str):
if isinstance(text, bytes):
raise TypeError("This isn't even decoded into Unicode yet. "
"Decode it first.")
if len(text) == 0:
@ -151,7 +151,10 @@ def text_badness(text):
- Improbable single-byte characters, such as ƒ or ¬
- Letters in somewhat rare scripts
'''
if PY3:
assert isinstance(text, str)
else:
assert isinstance(text, unicode)
errors = 0
very_weird_things = 0
weird_things = 0