diff --git a/src/callbacks.py b/src/callbacks.py index c647a8ac6..48a42cae6 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -294,9 +294,14 @@ class Tokenizer(object): token = token[1:-1] # FIXME: No need to tell you this is a hack. # It has to handle both IRC commands and serialized configuration. + # + # Whoever you are, if you make a single modification to this + # code, TEST the code with Python 2 & 3, both with the unit + # tests and on IRC with this: @echo "好" if sys.version_info[0] < 3: try: token = token.encode('utf8').decode('string_escape') + token = token.decode('utf8') except: token = token.decode('string_escape') else: diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 21626edda..76aa97424 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -73,10 +73,8 @@ class TokenizerTestCase(SupyTestCase): ['foo', 'bar baz', 'quux']) def testUnicode(self): - print repr((tokenize(u'好'), ['好'])) - print repr((tokenize(u'"好"'), ['好'])) - self.assertEqual(tokenize(u'好'), ['好']) - self.assertEqual(tokenize(u'"好"'), ['好']) + self.assertEqual(tokenize(u'好'), [u'好']) + self.assertEqual(tokenize(u'"好"'), [u'好']) def testNesting(self): self.assertEqual(tokenize('[]'), [[]])