From: Georg Brandl Date: Sat, 11 Dec 2010 19:10:30 +0000 (+0000) Subject: Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp... X-Git-Tag: v3.2b2~147 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab3734fd97cb060b3e39d0350df0e741ad3b7b11;p=python Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp call failed. --- 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