Message271775
I'm currently migrating a project that predates requests, and ended up needing to replace several "json.loads" calls with a "_load_json" helper that is just an alias for json.loads in Python 2, and defined as this in Python 3:
def _load_json(data):
return json.loads(data.decode())
To get that case to "just work", all I would have needed is for json.loads to accept bytes input, and assume it is UTF-8 encoded, that same way simplejson does. Since there aren't any type ambiguities associated with that, I think it would make sense for us to go ahead and implement at least that much for Python 3.6.
By contrast, if I'd been doing *encoding*, I don't think there's anything the Python 3 standard library could have changed *on its own* to make things just work - I would have needed to change my code somehow.
However, a new "dump_bytes" API could still be beneficial on that front as long as it was also added to simplejson: code that needed to run in the common Python 2/3 subset could use "simplejson.dump_bytes", while 3.6+ only code could just use the standard library version.
Having dump_bytes() next to dumps() in the documentation would also provide a better hook for explaining the difference between JSON-as-text-encoding (with "str" output) and JSON-as-wire-encoding (with "bytes" output after encoding the str representation as UTF-8).
In both cases, I think it would make sense to leave the non-UTF-8 support to simplejson and have the stdlib version be UTF-8 only. |
|
Date |
User |
Action |
Args |
2016-08-01 08:17:33 | ncoghlan | set | recipients:
+ ncoghlan, barry, terry.reedy, gregory.p.smith, chrism, pitrou, vstinner, kdwyer, ezio.melotti, eric.araujo, cvrebert, socketpair, martin.panter, serhiy.storchaka, jleedev |
2016-08-01 08:17:33 | ncoghlan | set | messageid: <1470039453.66.0.0129832315681.issue19837@psf.upfronthosting.co.za> |
2016-08-01 08:17:33 | ncoghlan | link | issue19837 messages |
2016-08-01 08:17:32 | ncoghlan | create | |
|