Changes by Serhiy Storchaka storch...@gmail.com:
--
status: pending - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22701
___
___
Serhiy Storchaka added the comment:
Looks either you have opened a file with the backslashreplace error handler or
ran Python with PYTHONIOENCODING which sets the backslashreplace error handler.
--
nosy: +serhiy.storchaka
status: open - pending
___
Ezio Melotti added the comment:
The example works for me with both python 2 and 3. I'm going to close this in
a while if OP doesn't reply.
$ python2 -c import json; json.dump({'name': '港区'}, open('py2.json', 'w'),
indent=4, separators=(',', ': '), ensure_ascii=False) cat py2.json
{
Michael Kuss added the comment:
Pardon the delay - this json dump function is embedded in a much larger script,
so it took some untangling to get it running on Python 3.3, and scrub some
personal identifying info from it. This script also does not work in Python 3.3:
File
R. David Murray added the comment:
That error message indicates you've opened the output file in binary mode
instead of text mode.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22701
___
New submission from Michael Kuss:
When running the following:
json.dump(['name': 港区], myfile.json, indent=4, separators=(',', ': '),
ensure_ascii=False)
the function escapes the unicode, even though I have explicitly asked to not
force to ascii:
\u6E2F\u533A
By changing __init__.py such
R. David Murray added the comment:
If I fix your example so it runs:
json.dump({'name': 港区}, open('myfile.json', 'w'), indent=4, separators=(',',
': '), ensure_ascii=False)
I get the expected output:
rdmurray@pydev:~/python/p34cat myfile.json
{
name: 港区
}
That example won't work in