Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp call failed.

This commit is contained in:
Georg Brandl 2010-12-11 19:10:30 +00:00
parent dd5909725c
commit ab3734fd97

View 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