[issue11489] json.dumps not parsable by json.loads (on Linux only)

Brian Merrell report at bugs.python.org
Mon Mar 14 18:31:42 CET 2011


Brian Merrell <brian at merrells.org> added the comment:

>I am not sure this should be fixed in 2.x. Lone surrogates seem to >round-trip just fine in 2.x and there likely to be existing code that >relies on this.

I generally agree but am then at a loss as to how to detect and deal with lone surrogates(eg "ignore", "replace", etc) in 2.x when interacting with services/libraries (such as Python's own json.loads) that take a stricter view.

>>  Shouldn't anything generated by json.dumps be parsed by json.loads?

>This on the other hand should probably be fixed by either rejecting >lone surrogates in json.dumps or accepting them in json.loads or both.  >The last alternative would be consistent with the common wisdom of >being conservative in what you produce but liberal in what you accept.

We seem to be in the worst of both worlds right now as I've generated and stored a lot of json that can not be read back in.  Could the JSON library simply leverage Python's Unicode interpreter instead of performing its own validation?  We could pass it "ignore", "replace", etc.  Regardless, I think we certainly need to remove the strict JSON loads() validation especially when it isn't enforced by dumps().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11489>
_______________________________________


More information about the Python-bugs-list mailing list