[ python-Bugs-1343671 ] Broken docs for os.removedirs

SourceForge.net noreply at sourceforge.net
Sat Nov 12 16:49:46 CET 2005


Bugs item #1343671, was opened at 2005-10-31 12:30
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1343671&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Kågedal (d_kagedal)
Assigned to: Nobody/Anonymous (nobody)
Summary: Broken docs for os.removedirs

Initial Comment:
The documentation for the os.removedirs function is
seriously broken.  This is from the library reference:

"removedirs(path)
    Removes directories recursively. Works like rmdir()
except that, if the leaf directory is successfully
removed, directories corresponding to rightmost path
segments will be pruned way until either the whole path
is consumed or an error is raised (which is ignored,
because it generally means that a parent directory is
not empty). Throws an error exception if the leaf
directory could not be successfully removed. New in
version 1.5.2."

The first sentence is the only part that makes any
sense. This shorter version contains as much
information and less misinformation"

"removedirs(path)
   Removes a directory and everything in it
recursively. If a file couldn't be removed, the removal
is aborted and you might get an exception if you're lucky."

The doc string you get when you type
"help(os.removedirs)" is different from the one in the
library reference, but equally broken.

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

>Comment By: Fredrik Lundh (effbot)
Date: 2005-11-12 16:49

Message:
Logged In: YES 
user_id=38376

Are you sure you understand how the function works?

Given "spam/egg/bacon", it first attempts to do an rmdir on
spam/egg/bacon.  If that fails, the function raises an
exception.  Otherwise, it proceeds to rmdir spam/egg and
spam. Errors during the latter stage are ignored.

If you want to remove directories whether they're empty or
not, use shutil.rmtree.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1343671&group_id=5470


More information about the Python-bugs-list mailing list