fix unicode string with Python3.2 bug in simplejson package

This commit is contained in:
Alan Hamlett 2014-06-06 15:13:31 -05:00
parent 0ae5f37a40
commit 5303f25614
36 changed files with 7 additions and 3726 deletions

View file

@ -18,7 +18,7 @@ from simplejson.decoder import PosInf
#ESCAPE = re.compile(ur'[\x00-\x1f\\"\b\f\n\r\t\u2028\u2029]')
# This is required because u() will mangle the string and ur'' isn't valid
# python3 syntax
ESCAPE = re.compile(u'[\\x00-\\x1f\\\\"\\b\\f\\n\\r\\t\u2028\u2029]')
ESCAPE = re.compile(u('[\\x00-\\x1f\\\\"\\b\\f\\n\\r\\t\u2028\u2029]'))
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
HAS_UTF8 = re.compile(r'[\x80-\xff]')
ESCAPE_DCT = {
@ -265,7 +265,7 @@ class JSONEncoder(object):
if self.ensure_ascii:
return ''.join(chunks)
else:
return u''.join(chunks)
return u('').join(chunks)
def iterencode(self, o, _one_shot=False):
"""Encode the given object and yield each string
@ -358,7 +358,7 @@ class JSONEncoderForHTML(JSONEncoder):
if self.ensure_ascii:
return ''.join(chunks)
else:
return u''.join(chunks)
return u('').join(chunks)
def iterencode(self, o, _one_shot=False):
chunks = super(JSONEncoderForHTML, self).iterencode(o, _one_shot)