]> granicus.if.org Git - python/commitdiff
Test that os.utime and os.chmod actually exist before using them.
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 7 Mar 2003 12:47:06 +0000 (12:47 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 7 Mar 2003 12:47:06 +0000 (12:47 +0000)
Lib/tarfile.py

index 32bb87efc8635c48b4e9a0fce8a5ed890cc5aff5..270c2b2b8f570556aafa42748fe7a8b51cf88769 100644 (file)
@@ -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.