Fix closes issue #12088 - fixes the tarfile.extractall issue when the
symlinks/hardlink was broken. It handles now in a graceful manner (No exception
is raised, behavior similar GNU tar).
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 105a758..6b9303e 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2239,12 +2239,14 @@
if hasattr(os, "symlink") and hasattr(os, "link"):
# For systems that support symbolic and hard links.
if tarinfo.issym():
- if os.path.exists(targetpath):
+ if os.path.lexists(targetpath):
os.unlink(targetpath)
os.symlink(tarinfo.linkname, targetpath)
else:
# See extract().
if os.path.exists(tarinfo._link_target):
+ if os.path.lexists(targetpath):
+ os.unlink(targetpath)
os.link(tarinfo._link_target, targetpath)
else:
self._extract_member(self._find_link_target(tarinfo), targetpath)