summaryrefslogtreecommitdiff
path: root/Lib/tempfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-12-11 19:10:30 +0000
committerGeorg Brandl <georg@python.org>2010-12-11 19:10:30 +0000
commitab3734fd97cb060b3e39d0350df0e741ad3b7b11 (patch)
tree3ffd7f083bcc7730cfaecc9d83cdae9fd3f72e46 /Lib/tempfile.py
parentdd5909725cf742574f5bd196c5ed338c43664457 (diff)
downloadcpython-git-ab3734fd97cb060b3e39d0350df0e741ad3b7b11.tar.gz
Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp call failed.
Diffstat (limited to 'Lib/tempfile.py')
-rw-r--r--Lib/tempfile.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index cbaac4300a..7e0378443e 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -617,6 +617,8 @@ class TemporaryDirectory(object):
"""
def __init__(self, suffix="", prefix=template, dir=None):
+ # cleanup() needs this and is called even when mkdtemp fails
+ self._closed = True
self.name = mkdtemp(suffix, prefix, dir)
self._closed = False