Add support for Python 2.4 to Windows rmtree_errorhandler.

This commit is contained in:
Carl Meyer 2011-03-23 00:33:32 -04:00
parent de7b398328
commit d4e8f6785e
1 changed files with 4 additions and 2 deletions

View File

@ -34,8 +34,10 @@ def rmtree_errorhandler(func, path, exc_info):
remove them, an exception is thrown. We catch that here, remove the
read-only attribute, and hopefully continue without problems."""
exctype, value = exc_info[:2]
# lookin for a windows error
if exctype is not WindowsError or 'Access is denied' not in str(value):
# On Python 2.4, it will be OSError number 13
# On all more recent Pythons, it'll be WindowsError number 5
if not ((exctype is WindowsError and value.args[0] == 5) or
(exctype is OSError and value.args[0] == 13)):
raise
# file type should currently be read only
if ((os.stat(path).st_mode & stat.S_IREAD) != stat.S_IREAD):