diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-07 12:47:06 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-03-07 12:47:06 (GMT) |
commit | 834eff6a4ca700cb39a820db03e8c185c1b5dcb5 (patch) | |
tree | a72b8b1366e3cce034eaf6a18f03060c3e6466c3 /Lib/tarfile.py | |
parent | 6e31aad9834d3bbca256d34e17faae7d2ffff097 (diff) | |
download | cpython-834eff6a4ca700cb39a820db03e8c185c1b5dcb5.zip cpython-834eff6a4ca700cb39a820db03e8c185c1b5dcb5.tar.gz cpython-834eff6a4ca700cb39a820db03e8c185c1b5dcb5.tar.bz2 |
Test that os.utime and os.chmod actually exist before using them.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 32bb87e..270c2b2 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1513,14 +1513,17 @@ class TarFile(object): def chmod(self, tarinfo, targetpath): """Set file permissions of targetpath according to tarinfo. """ - try: - os.chmod(targetpath, tarinfo.mode) - except EnvironmentError, e: - raise ExtractError, "could not change mode" + if hasattr(os, 'chmod'): + try: + os.chmod(targetpath, tarinfo.mode) + except EnvironmentError, e: + raise ExtractError, "could not change mode" 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. |