summaryrefslogtreecommitdiff
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 4839eb1aef..aca934a9b7 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2273,7 +2273,7 @@ class TarFile(object):
(platform limitation), we try to make a copy of the referenced file
instead of a link.
"""
- if hasattr(os, "symlink") and hasattr(os, "link"):
+ try:
# For systems that support symbolic and hard links.
if tarinfo.issym():
os.symlink(tarinfo.linkname, targetpath)
@@ -2282,7 +2282,15 @@ class TarFile(object):
if os.path.exists(tarinfo._link_target):
os.link(tarinfo._link_target, targetpath)
else:
- self._extract_member(self._find_link_target(tarinfo), targetpath)
+ self._extract_mem
+ except (AttributeError, NotImplementedError, WindowsError):
+ # AttributeError if no os.symlink
+ # NotImplementedError if on Windows XP
+ # WindowsError (1314) if the required privilege is not held by the client
+ if tarinfo.issym():
+ linkpath = os.path.join(os.path.dirname(tarinfo.name),tarinfo.linkname)
+ else:
+ linkpath = tarinfo.linkname
else:
try:
self._extract_member(self._find_link_target(tarinfo), targetpath)