1
0
Fork 0

Merging upstream version 2.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-07 00:48:48 +01:00
parent ab1302c465
commit 95bca6b33d
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
42 changed files with 1085 additions and 840 deletions

View file

@ -28,7 +28,7 @@ class _TempDirectory(object):
name = None
_closed = False
def __init__(self, suffix="", prefix='tmp', dir=None):
def __init__(self, suffix="", prefix="tmp", dir=None):
self.name = _tempfile.mkdtemp(suffix, prefix, dir)
def __repr__(self):
@ -42,13 +42,14 @@ class _TempDirectory(object):
try:
_shutil.rmtree(self.name)
except (TypeError, AttributeError) as ex:
if "None" not in '%s' % (ex,):
if "None" not in "%s" % (ex,):
raise
self._rmtree(self.name)
self._closed = True
if _warn and _warnings.warn:
_warnings.warn("Implicitly cleaning up {!r}".format(self),
ResourceWarning)
_warnings.warn(
"Implicitly cleaning up {!r}".format(self), ResourceWarning
)
def __exit__(self, exc, value, tb):
self.cleanup()
@ -57,8 +58,15 @@ class _TempDirectory(object):
# Issue a ResourceWarning if implicit cleanup needed
self.cleanup(_warn=True)
def _rmtree(self, path, _OSError=OSError, _sep=_os.path.sep,
_listdir=_os.listdir, _remove=_os.remove, _rmdir=_os.rmdir):
def _rmtree(
self,
path,
_OSError=OSError,
_sep=_os.path.sep,
_listdir=_os.listdir,
_remove=_os.remove,
_rmdir=_os.rmdir,
):
# Essentially a stripped down version of shutil.rmtree. We can't
# use globals because they may be None'ed out at shutdown.
if not isinstance(path, str):