def cleanup(self, _warn=False):
if self.name and not self._closed:
try:
self._rmtree(self.name)
except (TypeError, AttributeError) as ex:
# Issue #10188: Emit a warning on stderr
# if the directory could not be cleaned
# up due to missing globals
if "None" not in str(ex):
raise
six.print_("ERROR: {!r} while cleaning up {!r}".format(ex,
self,),
file=_sys.stderr)
return
self._closed = True
if _warn:
# This should be a ResourceWarning, but it is not available in
# Python 2.x.
self._warn("Implicitly cleaning up {!r}".format(self),
Warning)
评论列表
文章目录