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

gh-85567: Fix pickle and pickletools not closing files #94583

Closed
wants to merge 5 commits into from

Conversation

kj7rrv
Copy link
Contributor

@kj7rrv kj7rrv commented Jul 5, 2022

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

It goes in the right direction, but it cannot overcome the main innate defect of FileType. It leaves the files open if Python quits or fails before it has a chance to handle the opened files. For example, when pass option -t in the pickletools CLI. Or pass only the output file argument without input file arguments. Or when it fails processing an input file if several input file arguments are specified.

#113618 manages files more explicitly and does not have such issues.

dis(f, args.output, memo, args.indentlevel, annotate)
finally:
f.close()
args.output.close()
Copy link
Member

Choose a reason for hiding this comment

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

It is not correct to close the output file after processing the first input file.

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.

pickle and pickletools cli interface doesn't close input and output file.
4 participants