Issue #21775: shutil.copytree(): fix crash when copying to VFAT

An exception handler assumed that that OSError objects always have a
'winerror' attribute. That is not the case, so the exception handler
itself raised AttributeError when run on Linux (and, presumably, any
other non-Windows OS).

Patch by Greg Ward.
This commit is contained in:
Berker Peksag 2014-12-10 02:50:32 +02:00
parent 8b1cbd2b7c
commit 884afd92f5
3 changed files with 22 additions and 1 deletions

View file

@ -337,7 +337,7 @@ def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
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)