-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-33753: Refactor creating temporary files in test_fileinput. #7377
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-33753: Refactor creating temporary files in test_fileinput. #7377
Conversation
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.
LGTM. addCleanup() is a good solution.
I asked a question, but it shouldn't be a blocker issue.
Lib/test/test_fileinput.py
Outdated
count = 0 | ||
def writeTmp(self, content, *, mode='w'): # opening in text mode is the default | ||
self.count += 1 | ||
name = TESTFN + str(self.count) |
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.
Why not using tempfile.mktemp()? tempfile uses a temporary directory which is cleared sometimes at system boot. It prevents leaking temporary files if Python does crash.
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.
Good idea!
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.
Ah, I proposed mktemp() but mkstemp() may be even better.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
GH-7417 is a backport of this pull request to the 3.7 branch. |
…onGH-7377) (cherry picked from commit 5f48e26) Co-authored-by: Serhiy Storchaka <[email protected]>
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
) (cherry picked from commit 5f48e26) Co-authored-by: Serhiy Storchaka <[email protected]>
…pythonGH-7377). (cherry picked from commit 5f48e26) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-7431 is a backport of this pull request to the 3.6 branch. |
https://bugs.python.org/issue33753