Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-132631: Fix "I/O operation on closed file" when parsing JSON Lines file#132632
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Misc/NEWS.d/next/Library/2025-04-17-15-26-35.gh-issue-132631.IDFZfb.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
@@ -55,7 +55,7 @@ def main(): | |||
infile = open(options.infile, encoding='utf-8') | |||
try: | |||
if options.json_lines: | |||
objs = (json.loads(line) for line in infile) | |||
objs =tuple(json.loads(line) for line in infile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This has significant memory implications for large.jsonl
files. It might be better to instead move thefinally
clause either to the outertry
or just after thewith outfile
block, but that does have implications for theinfile == outfile
case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hmm, yeah, moving it gives a blank file wheninfile == outfile
...
python-cla-botbot commentedApr 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
Before
After