Skip to content

Commit

Permalink
fix unicode, not str error in utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
taishi-i committed Jun 19, 2020
1 parent af900a3 commit edf3427
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nagisa/utils.py
Expand Up @@ -12,7 +12,10 @@
from six.moves import cPickle


if sys.version_info.major == 2:
if sys.version_info.major == 3:
PY_3 = True
else:
PY_3 = False
reload(sys)
sys.setdefaultencoding('utf-8')

Expand All @@ -31,7 +34,7 @@


def utf8rstrip(text):
if type(text) != str:
if PY_3 is False:
return unicode(text.rstrip(), 'utf-8')
else:
return text.rstrip()
Expand All @@ -49,7 +52,7 @@ def preprocess(text):


def preprocess_without_rstrip(text):
if type(text) != str:
if PY_3 is False:
text = unicode(text, 'utf-8')
text = normalize(text)
text = text.replace(' ', ' ')
Expand Down

0 comments on commit edf3427

Please sign in to comment.