From ab3734fd97cb060b3e39d0350df0e741ad3b7b11 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 11 Dec 2010 19:10:30 +0000 Subject: [PATCH] Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp call failed. --- Lib/tempfile.py | 2 ++ 1 file changed, 2 insertions(+) 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 -- 2.40.0