mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #16800: tempfile.gettempdir() no longer left temporary files when
the disk is full. Original patch by Amir Szekely.
This commit is contained in:
commit
94cd10fa19
4 changed files with 51 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue