[issue21775] shutil.copytree() crashes copying to VFAT on Linux: AttributeError: 'PermissionError' object has no attribute 'winerror'

Greg Ward report at bugs.python.org
Sun Jun 15 23:44:19 CEST 2014


Greg Ward added the comment:

Bad news: because reproducing this requires sudo (to mount an arbitrary filesystem), I'm not sure it's possible/desirable to add test code for it.

Good news: the fix is trivial, and it passes my manual test. Here's a patch:

--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -336,7 +336,7 @@
         copystat(src, dst)
     except OSError as why:
         # Copying file access times may fail on Windows
-        if why.winerror is None:
+        if getattr(why, 'winerror', None) is None:
             errors.append((src, dst, str(why)))
     if errors:
         raise Error(errors)

Running test suite now to make sure this doesn't break anything else...

----------

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


More information about the Python-bugs-list mailing list