summaryrefslogtreecommitdiffstats
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-12 22:38:48 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-12 22:38:48 (GMT)
commit94cd10fa19d7174ce07c4680a1be7a94cb29dd8b (patch)
tree0aa07bbd57164c489e3f3a719705424a8166e056 /Lib/tempfile.py
parent38e2a2afbd627187790f89baa7673c4bbcaf8779 (diff)
parentff7fef9601d15cdf274b4b984c7638f33002e879 (diff)
downloadcpython-94cd10fa19d7174ce07c4680a1be7a94cb29dd8b.zip
cpython-94cd10fa19d7174ce07c4680a1be7a94cb29dd8b.tar.gz
cpython-94cd10fa19d7174ce07c4680a1be7a94cb29dd8b.tar.bz2
Issue #16800: tempfile.gettempdir() no longer left temporary files when
the disk is full. Original patch by Amir Szekely.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 908533f..21c7186 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -174,11 +174,14 @@ def _get_default_tempdir():
filename = _os.path.join(dir, name)
try:
fd = _os.open(filename, _bin_openflags, 0o600)
- fp = _io.open(fd, 'wb')
- fp.write(b'blat')
- fp.close()
- _os.unlink(filename)
- del fp, fd
+ try:
+ try:
+ fp = _io.open(fd, 'wb', buffering=0, closefd=False)
+ fp.write(b'blat')
+ finally:
+ _os.close(fd)
+ finally:
+ _os.unlink(filename)
return dir
except FileExistsError:
pass