Skip to content

Commit 53ed469

Browse files
committed
Fix TemporaryDirectory cleanup with a bytes name
1 parent 9ad7ae0 commit 53ed469

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎Lib/tempfile.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,13 @@ def __init__(self, suffix=None, prefix=None, dir=None,
987987
@classmethod
988988
def _rmtree(cls, name, ignore_errors=False, repeated=False, dir_fd=None,
989989
fullname=None):
990-
if fullname is None:
991-
fullname = name
990+
991+
# work with str paths throughout
992+
name = _os.fsdecode(name)
993+
fullname = name if fullname is None else _os.fsdecode(fullname)
992994

993995
def onexc(func, path, exc, direntry=None, dir_fd=None):
996+
path = _os.fsdecode(path)
994997
# On DragonFly BSD, UF_NOUNLINK removal fails with EISDIR, not EPERM.
995998
if isinstance(exc, (PermissionError, IsADirectoryError)):
996999
if repeated and path == name:

0 commit comments

Comments
 (0)