bpo-33753: Refactor creating temporary files in test_fileinput.#7377
Conversation
vstinner
left a comment
There was a problem hiding this comment.
LGTM. addCleanup() is a good solution.
I asked a question, but it shouldn't be a blocker issue.
| 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.
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.
vstinner
left a comment
There was a problem hiding this comment.
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 <storchaka@gmail.com>
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
) (cherry picked from commit 5f48e26) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…pythonGH-7377). (cherry picked from commit 5f48e26) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-7431 is a backport of this pull request to the 3.6 branch. |
https://bugs.python.org/issue33753