diff options
author | Lars Gustäbel <lars@gustaebel.de> | 2008-12-12 13:58:03 (GMT) |
---|---|---|
committer | Lars Gustäbel <lars@gustaebel.de> | 2008-12-12 13:58:03 (GMT) |
commit | 3b02742f7df5831eae5e23b80d2b19b4ee42f75b (patch) | |
tree | 2a8550381b4fbbd8bdfa813da77e03038ba17361 /Lib | |
parent | 4c96fa55258628fa917c3ccf2bf2d84070955dc1 (diff) | |
download | cpython-3b02742f7df5831eae5e23b80d2b19b4ee42f75b.zip cpython-3b02742f7df5831eae5e23b80d2b19b4ee42f75b.tar.gz cpython-3b02742f7df5831eae5e23b80d2b19b4ee42f75b.tar.bz2 |
Issue #4616: TarFile.utime(): Restore directory times on Windows.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/tarfile.py | 4 | ||||
-rw-r--r-- | Lib/test/test_tarfile.py | 9 |
2 files changed, 3 insertions, 10 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index ab74cc5..b678185 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2284,10 +2284,6 @@ class TarFile(object): """ 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. - return try: os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) except EnvironmentError, e: diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 7e4fd25..f5c9ed4 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -256,17 +256,14 @@ class MiscReadTest(ReadTest): def test_extractall(self): # Test if extractall() correctly restores directory permissions # and times (see issue1735). - if sys.platform == "win32": - # Win32 has no support for utime() on directories or - # fine grained permissions. - return - tar = tarfile.open(tarname, encoding="iso8859-1") directories = [t for t in tar if t.isdir()] tar.extractall(TEMPDIR, directories) for tarinfo in directories: path = os.path.join(TEMPDIR, tarinfo.name) - self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777) + if sys.platform != "win32": + # Win32 has no support for fine grained permissions. + self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777) self.assertEqual(tarinfo.mtime, os.path.getmtime(path)) tar.close() |