This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients barry, chrism, cvrebert, eric.araujo, ezio.melotti, gregory.p.smith, jleedev, kdwyer, martin.panter, ncoghlan, pitrou, serhiy.storchaka, socketpair, terry.reedy, vstinner
Date 2016-08-01.10:24:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1470047045.68.0.759505446098.issue19837@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2016-08-01 10:24:05ncoghlansetrecipients: + 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 10:24:05ncoghlansetmessageid: <1470047045.68.0.759505446098.issue19837@psf.upfronthosting.co.za>
2016-08-01 10:24:05ncoghlanlinkissue19837 messages
2016-08-01 10:24:05ncoghlancreate