From owner-freebsd-python@FreeBSD.ORG Tue Jul 27 17:27:52 2010 Return-Path: Delivered-To: python@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CEEA41065694 for ; Tue, 27 Jul 2010 17:27:52 +0000 (UTC) (envelope-from jhein@gossamer.timing.com) Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) by mx1.freebsd.org (Postfix) with ESMTP id A23E18FC1E for ; Tue, 27 Jul 2010 17:27:52 +0000 (UTC) Received: from gossamer.timing.com ([206.168.13.144]) by mrelay.perfora.net (node=mrus2) with ESMTP (Nemesis) id 0MNqOx-1OfAfD0Hed-007eCk; Tue, 27 Jul 2010 13:15:16 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19535.5151.37097.843093@gossamer.timing.com> Date: Tue, 27 Jul 2010 11:15:11 -0600 From: John Hein To: FreeBSD-gnats-submit@freebsd.org X-send-pr-version: 3.113 X-GNATS-Notify: X-Mailer: VM 8.0.12 under 22.3.1 (i386-redhat-linux-gnu) X-Provags-ID: V02:K0:JygeN/KjO8Ch4AAO8Ur8wPcUrifRk4MtNgJhkKg/F/n uDOE1WxTiBw3KcKfvCYJqIel6sFJfaYTUBwIdM0o25FHDQZKKe tRxA4epU/jFDt2nYaDB0tTVeu1LliT3YMfk+7psWxxu4pmTfKU 2e6rRzCofh+0D5Q4AS9mrgNUIfMYq8V1sGcH5TGNDhRDLIFQK/ pK4icgJSpaWWOeL4opBRQ== Cc: python@freebsd.org Subject: [patch] fix EOPNOTSUPP for copy2/copystat in python2.6 X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John Hein List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jul 2010 17:27:53 -0000 >Submitter-Id: current-users >Originator: John Hein >Organization: >Confidential: no >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 "", line 1, in 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").