Skip to content
Snippets Groups Projects
Commit ff9bc79f8313 authored by Bob Ippolito's avatar Bob Ippolito
Browse files
parent f11a669bab5e
Branches
No related tags found
No related merge requests found
......@@ -350,4 +350,5 @@
if (_encoding is not None
and not (_encoding == 'utf-8' and _need_utf8)):
o = o.decode(_encoding)
if self.ensure_ascii:
return encode_basestring_ascii(o)
......@@ -353,4 +354,6 @@
return encode_basestring_ascii(o)
else:
return encode_basestring(o)
# This doesn't pass the iterator directly to ''.join() because it
# sucks at reporting exceptions. It's going to do this internally
# anyway because it uses PySequence_Fast or similar.
......
......@@ -18,6 +18,26 @@
js = S.dumps(s, encoding='utf-8')
self.assertEquals(ju, js)
def test_encoding3(self):
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = S.dumps(u)
self.assertEquals(j, '"\\u03b1\\u03a9"')
def test_encoding4(self):
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = S.dumps([u])
self.assertEquals(j, '["\\u03b1\\u03a9"]')
def test_encoding5(self):
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = S.dumps(u, ensure_ascii=False)
self.assertEquals(j, u'"%s"' % (u,))
def test_encoding6(self):
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = S.dumps([u], ensure_ascii=False)
self.assertEquals(j, u'["%s"]' % (u,))
def test_big_unicode_encode(self):
u = u'\U0001d120'
self.assertEquals(S.dumps(u), '"\\ud834\\udd20"')
......@@ -21,7 +41,7 @@
def test_big_unicode_encode(self):
u = u'\U0001d120'
self.assertEquals(S.dumps(u), '"\\ud834\\udd20"')
self.assertEquals(S.dumps(u, ensure_ascii=False), '"\\ud834\\udd20"')
self.assertEquals(S.dumps(u, ensure_ascii=False), u'"\U0001d120"')
def test_big_unicode_decode(self):
u = u'z\U0001d120x'
......@@ -32,4 +52,4 @@
for i in range(0, 0xd7ff):
u = unichr(i)
json = '"\\u%04x"' % (i,)
self.assertEquals(S.loads(json), u)
\ No newline at end of file
self.assertEquals(S.loads(json), u)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment