Kaydet (Commit) 696d6ba6 authored tarafından Lars Gustäbel's avatar Lars Gustäbel

Merged revisions 67717 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r67717 | lars.gustaebel | 2008-12-12 14:58:03 +0100 (Fri, 12 Dec 2008) | 2 lines

  Issue #4616: TarFile.utime(): Restore directory times on Windows.
........
üst 717d5d0a
...@@ -2284,10 +2284,6 @@ class TarFile(object): ...@@ -2284,10 +2284,6 @@ class TarFile(object):
""" """
if not hasattr(os, 'utime'): if not hasattr(os, 'utime'):
return 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: try:
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
except EnvironmentError, e: except EnvironmentError, e:
......
...@@ -256,16 +256,13 @@ class MiscReadTest(ReadTest): ...@@ -256,16 +256,13 @@ class MiscReadTest(ReadTest):
def test_extractall(self): def test_extractall(self):
# Test if extractall() correctly restores directory permissions # Test if extractall() correctly restores directory permissions
# and times (see issue1735). # 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") tar = tarfile.open(tarname, encoding="iso8859-1")
directories = [t for t in tar if t.isdir()] directories = [t for t in tar if t.isdir()]
tar.extractall(TEMPDIR, directories) tar.extractall(TEMPDIR, directories)
for tarinfo in directories: for tarinfo in directories:
path = os.path.join(TEMPDIR, tarinfo.name) path = os.path.join(TEMPDIR, tarinfo.name)
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.mode & 0777, os.stat(path).st_mode & 0777)
self.assertEqual(tarinfo.mtime, os.path.getmtime(path)) self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
tar.close() tar.close()
......
...@@ -32,6 +32,8 @@ Core and Builtins ...@@ -32,6 +32,8 @@ Core and Builtins
Library Library
------- -------
- Issue #4616: TarFile.utime(): Restore directory times on Windows.
- Issue #4483: _dbm module now builds on systems with gdbm & gdbm_compat - Issue #4483: _dbm module now builds on systems with gdbm & gdbm_compat
libs. libs.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment