mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Issue #26385: Merge NamedTemporaryFile fix from 3.5
This commit is contained in:
commit
93088d1b03
3 changed files with 14 additions and 2 deletions
|
@ -552,7 +552,8 @@ def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
|
||||||
newline=newline, encoding=encoding)
|
newline=newline, encoding=encoding)
|
||||||
|
|
||||||
return _TemporaryFileWrapper(file, name, delete)
|
return _TemporaryFileWrapper(file, name, delete)
|
||||||
except Exception:
|
except BaseException:
|
||||||
|
_os.unlink(name)
|
||||||
_os.close(fd)
|
_os.close(fd)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -948,8 +948,16 @@ class TestNamedTemporaryFile(BaseTestCase):
|
||||||
self.assertRaises(ValueError, tempfile.NamedTemporaryFile)
|
self.assertRaises(ValueError, tempfile.NamedTemporaryFile)
|
||||||
self.assertEqual(len(closed), 1)
|
self.assertEqual(len(closed), 1)
|
||||||
|
|
||||||
# How to test the mode and bufsize parameters?
|
def test_bad_mode(self):
|
||||||
|
dir = tempfile.mkdtemp()
|
||||||
|
self.addCleanup(support.rmtree, dir)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
tempfile.NamedTemporaryFile(mode='wr', dir=dir)
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
tempfile.NamedTemporaryFile(mode=2, dir=dir)
|
||||||
|
self.assertEqual(os.listdir(dir), [])
|
||||||
|
|
||||||
|
# How to test the mode and bufsize parameters?
|
||||||
|
|
||||||
class TestSpooledTemporaryFile(BaseTestCase):
|
class TestSpooledTemporaryFile(BaseTestCase):
|
||||||
"""Test SpooledTemporaryFile()."""
|
"""Test SpooledTemporaryFile()."""
|
||||||
|
|
|
@ -194,6 +194,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #26385: Remove the file if the internal open() call in
|
||||||
|
NamedTemporaryFile() fails. Patch by Silent Ghost.
|
||||||
|
|
||||||
- Issue #26402: Fix XML-RPC client to retry when the server shuts down a
|
- Issue #26402: Fix XML-RPC client to retry when the server shuts down a
|
||||||
persistent connection. This was a regression related to the new
|
persistent connection. This was a regression related to the new
|
||||||
http.client.RemoteDisconnected exception in 3.5.0a4.
|
http.client.RemoteDisconnected exception in 3.5.0a4.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue