cpython: 5bfb4147405e (original) (raw)

Mercurial > cpython

changeset 100368:5bfb4147405e 2.7

Issue #26385: Cleanup NamedTemporaryFile if fdopen() fails, by SilentGhost [#26385]

Martin Panter vadmium+py@gmail.com
date Mon, 29 Feb 2016 00:31:38 +0000
parents 408891646a37
children 305ae007899b
files Lib/tempfile.py Lib/test/test_tempfile.py Misc/NEWS
diffstat 3 files changed, 12 insertions(+), 1 deletions(-)[+] [-] Lib/tempfile.py 3 Lib/test/test_tempfile.py 7 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -476,7 +476,8 @@ def NamedTemporaryFile(mode='w+b', bufsi try: file = _os.fdopen(fd, mode, bufsize) return _TemporaryFileWrapper(file, name, delete)

--- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -827,6 +827,13 @@ class test_NamedTemporaryFile(TC): os.close = old_close os.fdopen = old_fdopen

+ # How to test the mode and bufsize parameters? test_classes.append(test_NamedTemporaryFile)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -55,6 +55,9 @@ Core and Builtins Library ------- +- Issue #26385: Remove the file if the internal fdopen() call in