Date: Tue, 27 Jul 2010 11:15:11 -0600 From: John Hein <jhein@symmetricom.com> To: FreeBSD-gnats-submit@freebsd.org Cc: python@freebsd.org Subject: [patch] fix EOPNOTSUPP for copy2/copystat in python2.6 Message-ID: <19535.5151.37097.843093@gossamer.timing.com>
next in thread | raw e-mail | index | archive | help
>Submitter-Id: current-users >Originator: John Hein >Organization: >Confidential: no <FreeBSD PRs are public data> >Synopsis: [patch] fix EOPNOTSUPP for copy2/copystat in python2.6 >Severity: non-critical >Priority: medium >Category: ports >Class: sw-bug >Release: >Environment: >Description: shutil.copystat() can generate an exception when the source is FreeBSD and the destination is a filesystem that does not support chflags(2) (e.g., nfs, zfs). Also affected is shutil.copy2() which calls copystat(). This also affects various operations in mercurial which uses copy2. >How-To-Repeat: touch /tmp/file-on-freebsd-ufs python -c 'import shutil; shutil.copy2("/tmp/file-on-freebsd-ufs", "/dest/nfs/mount/.")' Traceback (most recent call last): File "<string>", line 1, in <module> File "/site/dist/python/lib/python2.6/shutil.py", line 100, in copy2 copystat(src, dst) File "/site/dist/python/lib/python2.6/shutil.py", line 77, in copystat os.chflags(dst, st.st_flags) OSError: [Errno 45] Operation not supported: '/dest/nfs/mount/./file-on-freebsd-ufs' >Fix: This is not needed for lang/python25 where copystat does not try to copy the flags. Index: Makefile =================================================================== RCS file: /base/FreeBSD-CVS/ports/lang/python26/Makefile,v retrieving revision 1.167 diff -u -p -r1.167 Makefile --- Makefile 19 Jul 2010 21:59:27 -0000 1.167 +++ Makefile 27 Jul 2010 16:54:18 -0000 @@ -6,7 +6,7 @@ PORTNAME= python26 PORTVERSION= 2.6.5 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= lang python ipv6 MASTER_SITES= ${PYTHON_MASTER_SITES} MASTER_SITE_SUBDIR= ${PYTHON_MASTER_SITE_SUBDIR} Index: files/patch-copystat =================================================================== RCS file: files/patch-copystat diff -N files/patch-copystat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-copystat 27 Jul 2010 16:53:46 -0000 @@ -0,0 +1,41 @@ +# $FreeBSD$ + +Work around 'Operation not supported' issues when using copystat() +(and copy2() which calls copystat()) to a filesystem destination +that does not support chflags(2) (e.g., nfs, zfs). + +http://bugs.python.org/issue7512 + +This has already been applied upstream and 2.7 has it already. + +http://svn.python.org/view/python/branches/release26-maint/Lib/shutil.py?view=diff&pathrev=79300&r1=79299&r2=79300 + +Also affects mercurial... + +http://www.selenic.com/pipermail/mercurial/2010-March/030716.html + +diff -r 4207e9a39b78 Lib/shutil.py +--- a/Lib/shutil.py Tue Dec 15 03:25:27 2009 +0000 ++++ b/Lib/shutil.py Tue Dec 15 15:25:31 2009 +0800 +@@ -9,6 +9,7 @@ + import stat + from os.path import abspath + import fnmatch ++import errno + + __all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2", + "copytree","move","rmtree","Error", "SpecialFileError"] +@@ -88,8 +89,11 @@ + 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").
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19535.5151.37097.843093>