Message220676
When using shutil.copytree() on Linux to copy to a VFAT filesystem, it crashes like this:
Traceback (most recent call last):
File "/data/src/cpython/3.4/Lib/shutil.py", line 336, in copytree
copystat(src, dst)
File "/data/src/cpython/3.4/Lib/shutil.py", line 190, in copystat
lookup("chmod")(dst, mode, follow_symlinks=follow)
PermissionError: [Errno 1] Operation not permitted: '/mnt/example_nt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "copytree-crash.py", line 14, in <module>
shutil.copytree('PC/example_nt', '/mnt/example_nt')
File "/data/src/cpython/3.4/Lib/shutil.py", line 339, in copytree
if why.winerror is None:
AttributeError: 'PermissionError' object has no attribute 'winerror'
I am *not* complaining about the PermissionError. That has been issue1545. Rather, I'm complaining about the crash that happens while attempting to handle the PermissionError.
Reproducing this is fairly easy, although it requires root privilege.
1. dd if=/dev/zero of=dummy bs=1024 count=1024
2. mkfs.vfat -v dummy
3. sudo mount -o loop /tmp/dummy /mnt
Then create the reproduction script in the root of Python's source dir:
cat > copytree-crash.py <<EOF
import os
import shutil
# assumptions:
# 1. /mnt is a directory writeable by current user
# 2. /mnt is a VFAT filesystem
# 3. current OS is Linux-ish
if os.path.exists('/mnt/example_nt'):
print('cleaning up')
shutil.rmtree('/mnt/example_nt')
print('copying')
shutil.copytree('PC/example_nt', '/mnt/example_nt')
EOF
and run it:
sudo ./python copytree-crash.py
Crash happens as documented above. |
|
Date |
User |
Action |
Args |
2014-06-15 21:37:40 | gward | set | recipients:
+ gward |
2014-06-15 21:37:40 | gward | set | messageid: <1402868260.95.0.79401871707.issue21775@psf.upfronthosting.co.za> |
2014-06-15 21:37:40 | gward | link | issue21775 messages |
2014-06-15 21:37:40 | gward | create | |
|