Test that os.utime and os.chmod actually exist before using them.
This commit is contained in:
parent
6e31aad983
commit
834eff6a4c
|
@ -1513,6 +1513,7 @@ 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 EnvironmentError, e:
|
||||
|
@ -1521,6 +1522,8 @@ class TarFile(object):
|
|||
def utime(self, tarinfo, targetpath):
|
||||
"""Set modification time of targetpath according to tarinfo.
|
||||
"""
|
||||
if not hasattr(os, 'utime'):
|
||||
return
|
||||
if sys.platform == "win32" and tarinfo.isdir():
|
||||
# According to msdn.microsoft.com, it is an error (EACCES)
|
||||
# to use utime() on directories.
|
||||
|
|
Loading…
Reference in New Issue