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-22831: Use "with" to avoid possible fd leaks in tools (part 2). #10927

Merged
merged 1 commit into from Mar 30, 2019

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Dec 5, 2018

Copy link
Member

@matrixise matrixise left a comment

@serhiy-storchaka excepted my comment, the PR seems to be ok.

@@ -97,7 +98,7 @@ def main():
exports = export_list(s)
f = sys.stdout # open('PC/python_nt.def','w')
f.write(DEF_TEMPLATE % (exports))
f.close()
# f.close()
Copy link
Member

@matrixise matrixise Mar 15, 2019

Choose a reason for hiding this comment

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

Why don't you close the file in this case?

with sys.stdout as fp:
    fp.write(DEF_TEMPLATE % (exports))

Copy link
Member Author

@serhiy-storchaka serhiy-storchaka Mar 16, 2019

Choose a reason for hiding this comment

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

No need to close the stdout.

Actually, closing the stdout looks suspicious.

@serhiy-storchaka serhiy-storchaka merged commit 172bb39 into python:master Mar 30, 2019
@serhiy-storchaka serhiy-storchaka deleted the fd-leaks-tools2 branch Mar 30, 2019
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.

None yet

4 participants