]> granicus.if.org Git - python/commitdiff
Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp...
authorGeorg Brandl <georg@python.org>
Sat, 11 Dec 2010 19:10:30 +0000 (19:10 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 11 Dec 2010 19:10:30 +0000 (19:10 +0000)
Lib/tempfile.py

index cbaac4300ac382ca0279fa7195f69e472e878c01..7e0378443e011beb6aeb4ba443e0be467ac5e150 100644 (file)
@@ -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