Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,9 @@ tarfile
now replace slashes with backslashes in symlink targets on Windows to prevent
creation of corrupted links.
(Contributed by Christoph Walcher in :gh:`57911`.)
* :func:`~tarfile.TarFile.gettarinfo` now replaces backslashes with slashes in
symlink targets on Windows to conform to the tar format standard. (Contributed
by Daniele Nicolodi in :gh:`151669`.)


threading
Expand Down
2 changes: 1 addition & 1 deletion Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ def gettarinfo(self, name=None, arcname=None, fileobj=None):
type = FIFOTYPE
elif stat.S_ISLNK(stmd):
type = SYMTYPE
linkname = os.readlink(name)
linkname = os.readlink(name).replace(os.sep, "/")
elif stat.S_ISCHR(stmd):
type = CHRTYPE
elif stat.S_ISBLK(stmd):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
On Windows, when populating tar archives from filesystem content, to
conform to the tar format standard, backslashes in symlink targets are
be replaced by slashes.
Loading