Skip to content

bpo-33684:parse failed for mutibytes characters, encode will show in \xxx#7286

Closed
zhouronghua wants to merge 2 commits intopython:masterfrom
zhouronghua:master
Closed

bpo-33684:parse failed for mutibytes characters, encode will show in \xxx#7286
zhouronghua wants to merge 2 commits intopython:masterfrom
zhouronghua:master

Conversation

@zhouronghua
Copy link

@zhouronghua zhouronghua commented May 31, 2018

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

@the-knights-who-say-ni
Copy link

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
and a Python core developer will remove the CLA not signed label
to make the bot check again.

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))
Copy link
Member

@pablogsal pablogsal Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pep8: Please, separate every argument with space:

outfile.write(json.dumps(obj, ensure_ascii=False, sort_keys=sort_keys, indent=4)

@brettcannon
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants