https://github.com/python/cpython/commit/562f08d6910f01e98f90e589ca5ee065fcbae53e
commit: 562f08d6910f01e98f90e589ca5ee065fcbae53e
branch: main
author: 0xd6cb6d73 <[email protected]>
committer: ethanfurman <[email protected]>
date: 2026-11-19T10:26:23-08:00
summary:

gh-143663: Perform path normalization in TarFile.extractall() (GH-143665)

only perform path separator replacement at lstat callsite

files:
A Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst
M Lib/tarfile.py

diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index b052ca0dd40729..ca6aea8396aaa1 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2554,7 +2554,7 @@ def extractall(self, path=".", members=None, *, 
numeric_owner=False,
                     continue
                 dirpath = os.path.join(path, tarinfo.name)
                 try:
-                    lstat = os.lstat(dirpath)
+                    lstat = os.lstat(dirpath.replace(r'/', os.sep))
                 except FileNotFoundError:
                     self._log_no_directory_fixup(tarinfo, 'missing')
                     continue
diff --git 
a/Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst 
b/Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst
new file mode 100644
index 00000000000000..8428770d51d734
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-01-10-17-39-09.gh-issue-143663.9LEFAf.rst
@@ -0,0 +1,2 @@
+:meth:`tarfile.TarFile.extractall` now uses OS-specific separators to call
+lstat.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to