Message130779
The following works on Win7x64 Python 2.6.5 and breaks on Ubuntu 10.04x64-2.6.5. This raises three issues:
1) Shouldn't anything generated by json.dumps be parsed by json.loads?
2) It appears this is an invalid unicode character. Shouldn't this be caught by decode("utf8")
3) Why does Windows raise no issue with this and Linux does?
import json
unicode_bytes = '\xed\xa8\x80'
unicode_string = unicode_bytes.decode("utf8")
json_encoded = json.dumps("my_key":unicode_string)
json.loads(json_encoded)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.6/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.6/json/decoder.py", line 336, in raw_decode
obj, end = self._scanner.iterscan(s, **kw).next()
File "/usr/lib/python2.6/json/scanner.py", line 55, in iterscan
rval, next_pos = action(m, context)
File "/usr/lib/python2.6/json/decoder.py", line 183, in JSONObject
value, end = iterscan(s, idx=end, context=context).next()
File "/usr/lib/python2.6/json/scanner.py", line 55, in iterscan
rval, next_pos = action(m, context)
File "/usr/lib/python2.6/json/decoder.py", line 155, in JSONString
return scanstring(match.string, match.end(), encoding, strict)
ValueError: Invalid \uXXXX escape: line 1 column 14 (char 14) |
|
Date |
User |
Action |
Args |
2011-03-13 23:17:20 | Brian.Merrell | set | recipients:
+ Brian.Merrell |
2011-03-13 23:17:20 | Brian.Merrell | set | messageid: <1300058240.59.0.513243746739.issue11489@psf.upfronthosting.co.za> |
2011-03-13 23:17:19 | Brian.Merrell | link | issue11489 messages |
2011-03-13 23:17:19 | Brian.Merrell | create | |
|