[issue14662] shutil.move broken in 2.7.3 on OSX (chflags fails)

Fabian Groffen report at bugs.python.org
Thu Apr 26 19:42:20 CEST 2012


Fabian Groffen <grobian at gentoo.org> added the comment:

% echo "test" > /var/tmp/testfile
% python
Python 2.7.3 (default, Apr 26 2012, 19:06:37) 
[GCC 4.2.1 (Gentoo 4.2.1_p5666, Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.move("/var/tmp/testfile", "./testfile");
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Gentoo/usr/lib/python2.7/shutil.py", line 299, in move
    copy2(src, real_dst)
  File "/Library/Gentoo/usr/lib/python2.7/shutil.py", line 129, in copy2
    copystat(src, dst)
  File "/Library/Gentoo/usr/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 45] Operation not supported: './testfile'
>>> 
% vi /Library/Gentoo/usr/lib/python2.7/shutil.py
% python
Python 2.7.3 (default, Apr 26 2012, 19:06:37) 
[GCC 4.2.1 (Gentoo 4.2.1_p5666, Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.move("/var/tmp/testfile", "./testfile");
45
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Gentoo/usr/lib/python2.7/shutil.py", line 300, in move
    copy2(src, real_dst)
  File "/Library/Gentoo/usr/lib/python2.7/shutil.py", line 130, in copy2
    copystat(src, dst)
  File "/Library/Gentoo/usr/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 45] Operation not supported: './testfile'
>>> 
% grep 45 /usr/include/sys/errno.h
#define ENOTSUP         45              /* Operation not supported */

I tried with a FAT16 formatted USB-disk, but there it doesn't fail, so I did some further digging.  MS-DOS FS (under OSX) just seems to support setting flags (I tried with stat.UF_HIDDEN, Finder no longer displays the file).

NFS, however, does NOT support any chflags call.

% python
Python 2.7.3 (default, Apr 26 2012, 19:06:37) 
[GCC 4.2.1 (Gentoo 4.2.1_p5666, Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
>>> print hasattr(errno, 'EOPNOTSUPP')
True
>>> print errno.EOPNOTSUPP
102
>>> 

102 obviously != 45

% grep 102 /usr/include/sys/errno.h
#define EOPNOTSUPP      102             /* Operation not supported on socket */

I believe Python got it mixed up here, we're looking for ENOTSUP, but that one doesn't exist, at least not here.

>>> print hasattr(errno, 'ENOTSUP')
False

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14662>
_______________________________________


More information about the Python-bugs-list mailing list