Skip to content

bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2).#10927

Merged
serhiy-storchaka merged 1 commit intopython:masterfrom
serhiy-storchaka:fd-leaks-tools2
Mar 30, 2019
Merged

bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2).#10927
serhiy-storchaka merged 1 commit intopython:masterfrom
serhiy-storchaka:fd-leaks-tools2

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

@matrixise matrixise left a comment

Choose a reason for hiding this comment

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

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

f = sys.stdout # open('PC/python_nt.def','w')
f.write(DEF_TEMPLATE % (exports))
f.close()
# f.close()
Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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 March 30, 2019 06:33
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.

4 participants