summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-02-28 05:22:20 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-02-28 05:22:20 (GMT)
commit7869a227795da08841f8139b69b7d4521b12e184 (patch)
treefa6da1d13f8e13379f3914e328cf25a10e5f5eac /Lib/tempfile.py
parent96421d6f1136292abfe8748903f11231fba6cb16 (diff)
downloadcpython-7869a227795da08841f8139b69b7d4521b12e184.zip
cpython-7869a227795da08841f8139b69b7d4521b12e184.tar.gz
cpython-7869a227795da08841f8139b69b7d4521b12e184.tar.bz2
Issue #26385: Cleanup NamedTemporaryFile if open() fails, by SilentGhost
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index c39820e..ad687b9 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -552,7 +552,8 @@ def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
newline=newline, encoding=encoding)
return _TemporaryFileWrapper(file, name, delete)
- except Exception:
+ except BaseException:
+ _os.unlink(name)
_os.close(fd)
raise