bpo-33684:parse failed for mutibytes characters, encode will show in \xxx#7286
bpo-33684:parse failed for mutibytes characters, encode will show in \xxx#7286zhouronghua wants to merge 2 commits intopython:masterfrom
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. When your account is ready, please add a comment in this pull request Thanks again to your contribution and we look forward to looking at it! |
| raise SystemExit(e) | ||
| with outfile: | ||
| json.dump(obj, outfile, sort_keys=sort_keys, indent=4) | ||
| outfile.write(json.dumps(obj,ensure_ascii=False,sort_keys=sort_keys, indent=4)) |
There was a problem hiding this comment.
Pep8: Please, separate every argument with space:
outfile.write(json.dumps(obj, ensure_ascii=False, sort_keys=sort_keys, indent=4)
|
Thanks for the PR, but closing as the CLA has not been signed within the last month. If you do decide to sign the CLA we can re-open this PR. |
when type this command in windows(xp or win7, all the same):
python -m json.tool xxx.txt xxx.json
if xxx.txt contains Chinese(or other multibytes characters):
if xxx.txt is encoded in ansi, xxx.json will encode Chinese as \xxx, very bad to see what they are;
if xxx.txt is encoded in utf8(without bom for most of the time), because with no bom, json.tool will think it is encoded in ansi, and decode fail.
as now, utf8 is widely use, set default to utf8 for most of the time when auto detect encoding failed
https://bugs.python.org/issue33684