-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
shutil.copy2 raises OSError if filesystem doesn't support chmod #70655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On filesystems that doesn't support
which is not acceptable since documentation says "copy2() never returns failure". |
I agree that copy2 should not fail because chmod fails. Could you please provide the entire traceback message when it fails (on both 2.7 and 3.4 or 3.5)? And what OS are you running on, and what filesystem? It looks like the error happens because errno=95 (EOPNOTSUPP, probably) isn't in the list of errors that _copyxattr catches, while (ENOTSUP=134 on Linux) is. I think the documentation is also incorrect. Of course copy2 can fail: what about out of disk space? I think the documentation is trying to say that copy2 never fails because it can't preserve metadata. And the wording in the docs "copy2() never returns failure" is also odd, it should say "copy2() never raises an exception because it cannot preserve file metadata". |
Actually it is a remote fs mounted via samba. OS is Linux. Tracebacks with Python versions I have: $ python2.7
Python 2.7.11 (default, Jan 11 2016, 21:04:40)
[GCC 5.3.1 20160101] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("src", "dst")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/usr/lib/python2.7/shutil.py", line 100, in copystat
os.chmod(dst, mode)
OSError: [Errno 95] Operation not supported: 'dst'
>>>
$ python3.4
Python 3.4.4 (default, Jan 5 2016, 15:35:18)
[GCC 5.3.1 20160101] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("src", "dst")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/shutil.py", line 246, in copy2
copystat(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.4/shutil.py", line 191, in copystat
lookup("chmod")(dst, mode, follow_symlinks=follow)
OSError: [Errno 95] Operation not supported: 'dst'
>>>
$ python3.5
Python 3.5.1+ (default, Jan 13 2016, 15:09:18)
[GCC 5.3.1 20160101] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("src", "dst")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/shutil.py", line 252, in copy2
copystat(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.5/shutil.py", line 197, in copystat
lookup("chmod")(dst, mode, follow_symlinks=follow)
OSError: [Errno 95] Operation not supported: 'dst'
>>> |
I have merged the PR with the change in the documentation, feel free to open a new PR for the other part of this issue. |
Thanks for improving the docs here! Looks like there's still the fix to be made re: |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: