Jakub Wilk <jw...@jwilk.net> added the comment:
I think issue29988 is unrelated, or at least not the whole story. These are samples of tracebacks I see when the file is left behind: Traceback (most recent call last): File "test-tmpfile.py", line 4, in <module> with tempfile.NamedTemporaryFile(dir='.'): File "/opt/python/lib/python3.8/tempfile.py", line 548, in NamedTemporaryFile (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type) File "/opt/python/lib/python3.8/tempfile.py", line 258, in _mkstemp_inner fd = _os.open(file, flags, 0o600) KeyboardInterrupt Traceback (most recent call last): File "test-tmpfile.py", line 4, in <module> with tempfile.NamedTemporaryFile(dir='.'): File "/opt/python/lib/python3.8/tempfile.py", line 548, in NamedTemporaryFile (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type) File "/opt/python/lib/python3.8/tempfile.py", line 269, in _mkstemp_inner return (fd, _os.path.abspath(file)) File "/opt/python/lib/python3.8/posixpath.py", line 371, in abspath path = os.fspath(path) KeyboardInterrupt Traceback (most recent call last): File "test-tmpfile.py", line 4, in <module> with tempfile.NamedTemporaryFile(dir='.'): File "/opt/python/lib/python3.8/tempfile.py", line 548, in NamedTemporaryFile (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type) File "/opt/python/lib/python3.8/tempfile.py", line 269, in _mkstemp_inner return (fd, _os.path.abspath(file)) File "/opt/python/lib/python3.8/posixpath.py", line 378, in abspath return normpath(path) File "/opt/python/lib/python3.8/posixpath.py", line 355, in normpath if comp in (empty, dot): KeyboardInterrupt In all cases the interrupt happened in the NamedTemporaryFile function, so before __enter__/__exit__ would have chance to do its job. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34157> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com