Commit dd48b902 authored by Victor Stinner's avatar Victor Stinner

Issue #21058: NamedTemporaryFile() closes the FD on any error, not only Exception

parent 367f5d37
......@@ -463,7 +463,7 @@ def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
try:
file = _os.fdopen(fd, mode, bufsize)
return _TemporaryFileWrapper(file, name, delete)
except Exception:
except:
_os.close(fd)
raise
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment