python: tarfile wouldn't extract hardlink.

and fail with "Operation not allowed".
* we now try to create the link and fallback to a file in case
of failure.
This commit is contained in:
Jerome Duval
2014-11-28 17:45:44 +00:00
parent 69e2d8d95f
commit 8af9876d36
2 changed files with 37 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
From bd2ce0285f6664a5fb6d1c7fdc590561bebf500f Mon Sep 17 00:00:00 2001
From e158682a7e7e4eaee89b0a319898cc81fe87a051 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 12 Mar 2014 21:17:06 +0000
Subject: initial Haiku patch
@@ -759,7 +759,7 @@ index 40ad843..24621ef 100644
1.8.3.4
From 0a4292a9f64ebbb69ec9863b3397b1d2e9b30538 Mon Sep 17 00:00:00 2001
From 5f8c5e79e84950d038d1c62328eef90c457de7b7 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 5 Apr 2014 21:16:40 +0000
Subject: fix pyconfig.h path
@@ -782,7 +782,7 @@ index cf75650..bb54b6f 100644
1.8.3.4
From 4c3a87e1bf6ec0a7bb5ae2e8da3620ab17268697 Mon Sep 17 00:00:00 2001
From a769fb6232923674b192bb7332027f1e12209084 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Wed, 18 Jun 2014 12:19:13 +0000
Subject: Import missed change from the 2.6.9 patches
@@ -814,7 +814,7 @@ index f1b0ae8..c18a7dd 100644
1.8.3.4
From 818b7cffe7fa08b66a1e395db39f7d85ae42fb67 Mon Sep 17 00:00:00 2001
From 7f0ea727b5110c0cbb4f88b7c4851ea431215f95 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 21 Sep 2014 18:59:44 +0200
Subject: gcc2 fix.
@@ -836,3 +836,35 @@ index 650ca69..02a1913 100644
--
1.8.3.4
From 73930d516fe87aced15e67cd27cb221810ff1cdd Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 28 Nov 2014 16:26:28 +0000
Subject: tarfile: let link fail and catch exception.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 44ecd24..7a0b4e3 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2238,7 +2238,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():
if os.path.lexists(targetpath):
@@ -2252,7 +2252,7 @@ class TarFile(object):
os.link(tarinfo._link_target, targetpath)
else:
self._extract_member(self._find_link_target(tarinfo), targetpath)
- else:
+ except (os.error, AttributeError):
try:
self._extract_member(self._find_link_target(tarinfo), targetpath)
except KeyError:
--
1.8.3.4