diff options
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r-- | Lib/tempfile.py | 13 |
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 |