Skip to content

Commit 4f4ced3

Browse files
committed
Fix TemporaryDirectory cleanup with a bytes name
1 parent 5634c13 commit 4f4ced3

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
@@ -931,10 +931,13 @@ def __init__(self, suffix=None, prefix=None, dir=None,
931931
@classmethod
932932
def _rmtree(cls, name, ignore_errors=False, repeated=False, dir_fd=None,
933933
fullname=None):
934-
if fullname is None:
935-
fullname = name
934+
935+
# work with str paths throughout
936+
name = _os.fsdecode(name)
937+
fullname = name if fullname is None else _os.fsdecode(fullname)
936938

937939
def onerror(func, path, exc_info, direntry=None, dir_fd=None):
940+
path = _os.fsdecode(path)
938941
if issubclass(exc_info[0], PermissionError):
939942
if repeated and path == name:
940943
if ignore_errors:

0 commit comments

Comments
 (0)