mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Final encoding fix. It now work on IRC and unit tests pass, both with Python 2 & 3.
This commit is contained in:
parent
a4a595b39a
commit
30c5519acb
@ -294,9 +294,14 @@ class Tokenizer(object):
|
|||||||
token = token[1:-1]
|
token = token[1:-1]
|
||||||
# FIXME: No need to tell you this is a hack.
|
# FIXME: No need to tell you this is a hack.
|
||||||
# It has to handle both IRC commands and serialized configuration.
|
# 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:
|
if sys.version_info[0] < 3:
|
||||||
try:
|
try:
|
||||||
token = token.encode('utf8').decode('string_escape')
|
token = token.encode('utf8').decode('string_escape')
|
||||||
|
token = token.decode('utf8')
|
||||||
except:
|
except:
|
||||||
token = token.decode('string_escape')
|
token = token.decode('string_escape')
|
||||||
else:
|
else:
|
||||||
|
@ -73,10 +73,8 @@ class TokenizerTestCase(SupyTestCase):
|
|||||||
['foo', 'bar baz', 'quux'])
|
['foo', 'bar baz', 'quux'])
|
||||||
|
|
||||||
def testUnicode(self):
|
def testUnicode(self):
|
||||||
print repr((tokenize(u'好'), ['好']))
|
self.assertEqual(tokenize(u'好'), [u'好'])
|
||||||
print repr((tokenize(u'"好"'), ['好']))
|
self.assertEqual(tokenize(u'"好"'), [u'好'])
|
||||||
self.assertEqual(tokenize(u'好'), ['好'])
|
|
||||||
self.assertEqual(tokenize(u'"好"'), ['好'])
|
|
||||||
|
|
||||||
def testNesting(self):
|
def testNesting(self):
|
||||||
self.assertEqual(tokenize('[]'), [[]])
|
self.assertEqual(tokenize('[]'), [[]])
|
||||||
|
Loading…
Reference in New Issue
Block a user