From ad1c376d39f1a07c4a00b6531f2ce1223e9183d6 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Thu, 22 Dec 2011 22:38:10 +0000 Subject: [PATCH] Fixed a missing exception (`WindowsError`) when using the rmtree error handler on non-Windows systems. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17247 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/_os.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/django/utils/_os.py b/django/utils/_os.py index 2c7b88e2c3..ad4efb3264 100644 --- a/django/utils/_os.py +++ b/django/utils/_os.py @@ -3,11 +3,18 @@ import stat from os.path import join, normcase, normpath, abspath, isabs, sep from django.utils.encoding import force_unicode -# Define our own abspath function that can handle joining +try: + WindowsError = WindowsError +except NameError: + class WindowsError(Exception): + pass + + +# Define our own abspath function that can handle joining # unicode paths to a current working directory that has non-ASCII -# characters in it. This isn't necessary on Windows since the +# characters in it. This isn't necessary on Windows since the # Windows version of abspath handles this correctly. The Windows -# abspath also handles drive letters differently than the pure +# abspath also handles drive letters differently than the pure # Python implementation, so it's best not to replace it. if os.name == 'nt': abspathu = abspath @@ -45,6 +52,7 @@ def safe_join(base, *paths): 'path component (%s)' % (final_path, base_path)) return final_path + def rmtree_errorhandler(func, path, exc_info): """ On Windows, some files are read-only (e.g. in in .svn dirs), so when