From 9fcd4b3d294a8e4c83dc2d0a4cc6da3cf87268d8 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 11 Aug 2008 17:21:36 +0000 Subject: [PATCH] #3134: shutil referenced undefined WindowsError symbol --- Lib/shutil.py | 14 ++++++++++---- Misc/NEWS | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Lib/shutil.py b/Lib/shutil.py index 3af280dd42e..ae2c66cef1e 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 diff --git a/Misc/NEWS b/Misc/NEWS index 1c346545ba0..398740224f0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -44,6 +44,8 @@ Core and Builtins Library ------- +- Issue #3134: shutil referenced undefined WindowsError symbol. + - Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to menu entries were not deleted.