diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2008-08-11 17:21:36 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2008-08-11 17:21:36 +0000 |
commit | 9fcd4b3d294a8e4c83dc2d0a4cc6da3cf87268d8 (patch) | |
tree | aacc9dd46a398c2c02c23e96276d24757b078570 /Lib/shutil.py | |
parent | 48361f5cbf419cce361fd1aa0389d6304ad167db (diff) | |
download | cpython-git-9fcd4b3d294a8e4c83dc2d0a4cc6da3cf87268d8.tar.gz |
#3134: shutil referenced undefined WindowsError symbol
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r-- | Lib/shutil.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py index 3af280dd42..ae2c66cef1 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -16,6 +16,11 @@ __all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2", class Error(EnvironmentError): pass +try: + WindowsError +except NameError: + WindowsError = None + def copyfileobj(fsrc, fdst, length=16*1024): """copy data from file-like object fsrc to file-like object fdst""" while 1: @@ -162,11 +167,12 @@ def copytree(src, dst, symlinks=False, ignore=None): errors.extend(err.args[0]) try: copystat(src, dst) - except WindowsError: - # can't copy file access times on Windows - pass except OSError, why: - errors.extend((src, dst, str(why))) + if WindowsError is not None and isinstance(why, WindowsError): + # Copying file access times may fail on Windows + pass + else: + errors.extend((src, dst, str(why))) if errors: raise Error, errors |