Author r.david.murray
Recipients Tom.Christie, georg.brandl, r.david.murray
Date 2014-10-30.20:00:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414699207.89.0.944178850745.issue22767@psf.upfronthosting.co.za>
In-reply-to
Content
Or, to put it another way, we agree with you that both cases should behave the same: using binary data in a json dumps call should raise an error.  And in python3 they do.  But in python2 there is a confusion as to what is text and what is binary, and so sometimes things work that shouldn't.  In python2 a binary string with non-ascii characters is accepted by the dumps call...it shouldn't be since json is defined as a text protocol.  But it is baked into the python2 string model that it such binary does work, because in python2 it was assumed that the programmer was responsible for making sure that the encoding of all their binary strings was consistent.   But to mix unicode and binary, you *must* make the encoding of the binary strings explicit, otherwise there's no way to correctly compose the binary data with the text data.
So, as soon as (but only as soon as) you mix unicode with your non-ascii data, your program blows up.

Thus python3.
History
Date User Action Args
2014-10-30 20:00:07r.david.murraysetrecipients: + r.david.murray, georg.brandl, Tom.Christie
2014-10-30 20:00:07r.david.murraysetmessageid: <1414699207.89.0.944178850745.issue22767@psf.upfronthosting.co.za>
2014-10-30 20:00:07r.david.murraylinkissue22767 messages
2014-10-30 20:00:07r.david.murraycreate