summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-02-25 22:32:27 (GMT)
committerGiampaolo Rodola <g.rodola@gmail.com>2019-02-25 22:32:27 (GMT)
commit8377cd4fcd0d51d86834c9b0518d29aac3b49e18 (patch)
treee8d82c3567b2d39ff0bd285d25ce2d02359ae070 /Lib/tarfile.py
parent9c3f284de598550be6687964c23fd7599e53b20e (diff)
downloadcpython-8377cd4fcd0d51d86834c9b0518d29aac3b49e18.zip
cpython-8377cd4fcd0d51d86834c9b0518d29aac3b49e18.tar.gz
cpython-8377cd4fcd0d51d86834c9b0518d29aac3b49e18.tar.bz2
Clean up code which checked presence of os.{stat,lstat,chmod} (#11643)
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-xLib/tarfile.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index ba3e95f..bb09d10 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1787,10 +1787,9 @@ class TarFile(object):
tarinfo = self.tarinfo()
tarinfo.tarfile = self # Not needed
- # Use os.stat or os.lstat, depending on platform
- # and if symlinks shall be resolved.
+ # Use os.stat or os.lstat, depending on if symlinks shall be resolved.
if fileobj is None:
- if hasattr(os, "lstat") and not self.dereference:
+ if not self.dereference:
statres = os.lstat(name)
else:
statres = os.stat(name)
@@ -2235,11 +2234,10 @@ class TarFile(object):
def chmod(self, tarinfo, targetpath):
"""Set file permissions of targetpath according to tarinfo.
"""
- if hasattr(os, 'chmod'):
- try:
- os.chmod(targetpath, tarinfo.mode)
- except OSError:
- raise ExtractError("could not change mode")
+ try:
+ os.chmod(targetpath, tarinfo.mode)
+ except OSError:
+ raise ExtractError("could not change mode")
def utime(self, tarinfo, targetpath):
"""Set modification time of targetpath according to tarinfo.