Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-45644: Make json.tool read infile before writing to outfile #29273

Merged
merged 4 commits into from
Nov 6, 2021

Conversation

CharString
Copy link
Contributor

@CharString CharString commented Oct 28, 2021

So that

$ python -m json.tool foo.json foo.json

doens't result in an empty foo.json, but with a reformatted version of the original.

https://bugs.python.org/issue45644

Chris Wesseling added 2 commits October 28, 2021 14:47
So that

$ python -m json.tool foo.json foo.json

doens't result in an empty foo.json.
@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 this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@CharString

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@tirkarthi
Copy link
Member

This seems to be a duplicate of https://bugs.python.org/issue33927

@tirkarthi
Copy link
Member

#7865

@serhiy-storchaka
Copy link
Member

Wrong bpo number.

@CharString CharString changed the title bpo-45664: Make json.tool soak up infile before writing to outfile bpo-45644: Make json.tool soak up infile before writing to outfile Oct 29, 2021
@CharString
Copy link
Contributor Author

@tirkarthi Looks like it is. Sorry for not searching thoroughly enough. I just bumped into this, already spent time trying to remember the name of sponge and then thought, why not make the tool itself soak up the input, the way sort -o does.

I've had a look and #7865 looks overly complex to me.
I agree with @rhettinger that "skip the argparse.FileType()" is "a Better Way™" bump fist on table 😁

@methane
Copy link
Member

methane commented Nov 4, 2021

Would you write a NEWS entry?

@methane methane changed the title bpo-45644: Make json.tool soak up infile before writing to outfile bpo-45644: Make json.tool read infile before writing to outfile Nov 4, 2021
@methane methane changed the title bpo-45644: Make json.tool read infile before writing to outfile bpo-45644: Make json.tool read infile before writing to outfile Nov 4, 2021
@ambv ambv added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Nov 6, 2021
@ambv ambv merged commit 815dad4 into python:main Nov 6, 2021
@miss-islington
Copy link
Contributor

Thanks @CharString for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 6, 2021
…onGH-29273)

so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 815dad4)

Co-authored-by: Chris Wesseling <chris.wesseling@protonmail.com>
@bedevere-bot
Copy link

GH-29445 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Nov 6, 2021
@bedevere-bot
Copy link

GH-29446 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Nov 6, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 6, 2021
…onGH-29273)

so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 815dad4)

Co-authored-by: Chris Wesseling <chris.wesseling@protonmail.com>
ambv pushed a commit that referenced this pull request Nov 6, 2021
…9273) (GH-29445)

so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 815dad4)

Co-authored-by: Chris Wesseling <chris.wesseling@protonmail.com>
ambv pushed a commit that referenced this pull request Nov 6, 2021
…9273) (GH-29446)

so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 815dad4)

Co-authored-by: Chris Wesseling <chris.wesseling@protonmail.com>
@CharString CharString deleted the bpo-45664 branch November 8, 2021 08:10
@CharString
Copy link
Contributor Author

Thanks everyone involved (bots included) for making this as pleasant a process as it could be.

remykarem pushed a commit to remykarem/cpython that referenced this pull request Dec 7, 2021
…onGH-29273)

so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
remykarem pushed a commit to remykarem/cpython that referenced this pull request Jan 30, 2022
…onGH-29273)

so that

$ python -m json.tool foo.json foo.json

doesn't result in an empty foo.json.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants