mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Issue #4616: TarFile.utime(): Restore directory times on Windows.
This commit is contained in:
		
							parent
							
								
									4c96fa5525
								
							
						
					
					
						commit
						3b02742f7d
					
				
					 3 changed files with 5 additions and 10 deletions
				
			
		|  | @ -2284,10 +2284,6 @@ def utime(self, tarinfo, targetpath): | ||||||
|         """ |         """ | ||||||
|         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,17 +256,14 @@ def test_extract_hardlink(self): | ||||||
|     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) | ||||||
|             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)) |             self.assertEqual(tarinfo.mtime, os.path.getmtime(path)) | ||||||
|         tar.close() |         tar.close() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -74,6 +74,8 @@ Core and Builtins | ||||||
| Library | Library | ||||||
| ------- | ------- | ||||||
| 
 | 
 | ||||||
|  | - Issue #4616: TarFile.utime(): Restore directory times on Windows. | ||||||
|  | 
 | ||||||
| - Issue #4084: Fix max, min, max_mag and min_mag Decimal methods to | - Issue #4084: Fix max, min, max_mag and min_mag Decimal methods to | ||||||
|   give correct results in the case where one argument is a quiet NaN |   give correct results in the case where one argument is a quiet NaN | ||||||
|   and the other is a finite number that requires rounding. |   and the other is a finite number that requires rounding. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lars Gustäbel
						Lars Gustäbel