Nick Coghlan added the comment:

dump_bytes() would be a binary counterpart to dumps()

The dump() case is already handled more gracefully, as the implicit encoding to 
UTF-8 can live on the file-like object, rather than needing to be handled by 
the JSON encoder.

I'm still not 100% sure on its utility though - it's only "json.loads assuming 
binary input is UTF-8 encoded text would be way more helpful than the current 
behaviour" that I'm confident about. If the assumption is wrong, you'll likely 
fail JSON deserialisation anyway, and when it's right, the common subset of 
Python 2 & 3 has been expanded in a useful way.

So perhaps we should split the question into two issues? A new one for 
accepting binary data as an input to json.loads, and make this one purely about 
whether or not to offer a combined serialise-and-encode operation for the wire 
protocol use case?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19837>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to