Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(33354)

Unified Diff: Lib/tarfile.py

Issue 23228: Crashes when tarfile contains a symlink and unpack directory contain it too
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/test/test_tarfile.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -55,13 +55,7 @@
grp = pwd = None
# os.symlink on Windows prior to 6.0 raises NotImplementedError
-symlink_exception = (AttributeError, NotImplementedError)
-try:
- # OSError (winerror=1314) will be raised if the caller does not hold the
- # SeCreateSymbolicLinkPrivilege privilege
- symlink_exception += (OSError,)
-except NameError:
- pass
+symlink_exception = (AttributeError, NotImplementedError, OSError)
# from tarfile import *
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError", "ReadError",
@@ -2205,7 +2199,12 @@
else:
self._extract_member(self._find_link_target(tarinfo),
targetpath)
- except symlink_exception:
+ except symlink_exception as e:
+ # On Windows, OSError (winerror=1314) will be raised if the caller
+ # does not hold the SeCreateSymbolicLinkPrivilege privilege.
+ if getattr(e, "winerror", None) is None:
Martin Panter 2018/12/15 23:44:46 What about AttributeError and NotImplementedError,
+ raise
+
try:
self._extract_member(self._find_link_target(tarinfo),
targetpath)
« no previous file with comments | « no previous file | Lib/test/test_tarfile.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+