[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread R. David Murray
R. David Murray added the comment: Yes, that third party problem is a prime example of exactly why this needed to be fixed, but it required python3 to fix it. -- ___ Python tracker

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread Tom Christie
Tom Christie added the comment: > So, as soon as (but only as soon as) you mix unicode with your non-ascii > data, your program blows up. Indeed. For context tho my example of running into this the unicode literals used as seperators weren't even in the same package as the non-ASCII binary st

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread R. David Murray
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 some

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread R. David Murray
R. David Murray added the comment: No, it is introducing the unicode that is the problem. Your first example is entirely binary. It is only when you *mix* binary and unicode that you have encoding problems (because python doesn't know the encoding of the binary data...well, more precisely it

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread Tom Christie
Tom Christie added the comment: > But only if you use non-ascii in the binary input, in which case you get an > encoding error, which is a correct error. Kind of, except that this (python 2.7) works just fine: >>> data = {'snowman': '☃'} >>> json.dumps(data, ensure_ascii=False) '{"

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread R. David Murray
R. David Murray added the comment: But only if you use non-ascii in the binary input, in which case you get an encoding error, which is a correct error. -- ___ Python tracker __

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread Tom Christie
Tom Christie added the comment: Not too fussed if this is addressed or not, but I think this is closed a little prematurely. I don't think there's a problem under Python 3, that's entirely reasonable. However under Python 2, `json.dumps()` will normally handle *either* bytes or unicode transp

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread R. David Murray
R. David Murray added the comment: And that works, including with the future import. I don't remember if this is a bug we've fixed since 2.7.2, but I don't think so. In Python3, json explicitly does not support bytes. -- nosy: +r.david.murray resolution: -> not a bug stage: -> resol

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread Georg Brandl
Georg Brandl added the comment: > in the second example or even, in both examples. -- ___ Python tracker ___ ___ Python-bugs-list mai

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread Georg Brandl
Georg Brandl added the comment: IMO the snowman should be a Unicode string in the second example for Python 2.7. -- nosy: +georg.brandl ___ Python tracker ___ ___

[issue22767] `separators` argument to json.dumps() behaves unexpectedly across 2.x vs 3.x

2014-10-30 Thread Tom Christie
New submission from Tom Christie: This is one of those behavioural issues that is a borderline bug. The seperators argument to `json.dumps()` behaves differently across python 2 and 3. * In python 2 it should be provided as a bytestring, and can cause a UnicodeDecodeError otherwise. * In pyth