[Patches] [ python-Patches-566517 ] fix bug in shutil.rmtree exception case

noreply@sourceforge.net noreply@sourceforge.net
Mon, 10 Jun 2002 13:11:11 -0700


Patches item #566517, was opened at 2002-06-09 14:17
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=566517&group_id=5470

Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Karl Fogel (kfogel)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix bug in shutil.rmtree exception case

Initial Comment:
The shutil.rmtree() library function promises to ignore
or handle
exceptions if the optional `ignore_errors' or
`onerrror' parameters
are passed, respectively.

However, if you invoke rmtree() on a non-existent path, the
exception is not caught within the exception-handling
block,
and so the exception is not ignored or handled even if
the caller
passed ignore_error or onerror.

The problem is due to the fact that the helper function
_build_cmdtuples() is called from outside the
exception-handling
block.  This patch rearranges rmtree() a bit, so that
exceptions from
_build_cmdtuples() are handled too.

The log message is included in the attached patch, and also
here for convenience:

2002-06-09  Karl Fogel  <kfogel@collab.net>

   * python/dist/src/Lib/shutil.py
   (rmtree): Place _build_cmdtuple within the
try/except too.

   * python/dist/src/Doc/lib/libshutil.tex
   (rmtree): Don't promise that errors will come only
from os.remove
   or os.rmdir anymore, since the exception catching is
now expanded.

I generated the patch against the Python CVS tree of
Sunday,
9 June 2002.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-10 16:11

Message:
Logged In: YES 
user_id=6380

The patch introduces a change in semantics: originally, the
error handler could be called any number of times. The new
version handles one error but then stops removing further
files.

Maybe the docs could be updated, but I don't think the
intention of the function was ever to catch errors when path
doesn't exist. The error handling is for situations where
some files can't be removed.

So I'm rejecting this.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=566517&group_id=5470