R. David Murray added the comment:

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.

----------

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

Reply via email to