From f5770f12d111932f742ec9d333e18c97aa02e855 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 11 Nov 2014 12:00:22 +0100 Subject: [PATCH] fix fixunicode --- ox/fixunicode.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ox/fixunicode.py b/ox/fixunicode.py index 3d8d1e8..b49e277 100644 --- a/ox/fixunicode.py +++ b/ox/fixunicode.py @@ -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 ''' - assert isinstance(text, str) + if PY3: + assert isinstance(text, str) + else: + assert isinstance(text, unicode) errors = 0 very_weird_things = 0 weird_things = 0