]> granicus.if.org Git - python/commitdiff
Issue #7512: shutil.copystat() could raise an OSError when the filesystem
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 22 Mar 2010 19:59:46 +0000 (19:59 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 22 Mar 2010 19:59:46 +0000 (19:59 +0000)
didn't support chflags() (for example ZFS under FreeBSD).  The error is
now silenced.

Lib/shutil.py
Misc/NEWS

index df571e71ad953377f0244b87cbbebc4a9cdee51a..0dfc7c7fe0906fac63c1c69df43e1afe1422421e 100644 (file)
@@ -11,6 +11,7 @@ from os.path import abspath
 import fnmatch
 from warnings import warn
 import collections
+import errno
 
 try:
     from pwd import getpwnam
@@ -105,8 +106,11 @@ def copystat(src, dst):
     if hasattr(os, 'chmod'):
         os.chmod(dst, mode)
     if hasattr(os, 'chflags') and hasattr(st, 'st_flags'):
-        os.chflags(dst, st.st_flags)
-
+        try:
+            os.chflags(dst, st.st_flags)
+        except OSError, why:
+            if not hasattr(errno, 'EOPNOTSUPP') or why.errno != errno.EOPNOTSUPP:
+                raise
 
 def copy(src, dst):
     """Copy data and mode bits ("cp src dst").
index 1824f5f84834a0fc837c3dfe68a71b41416fb4c8..f207082978bb2ceed9b27c707b171024476aee35 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #7512: shutil.copystat() could raise an OSError when the filesystem
+  didn't support chflags() (for example ZFS under FreeBSD).  The error is
+  now silenced.
+
 - Issue #7703: ctypes supports both buffer() and memoryview().  The former is
   deprecated.