Kaydet (Commit) 234d9a9e authored tarafından Barry Warsaw's avatar Barry Warsaw

rmtree(): Make implementation agree with documentation (both latex and

docstring).  Even if ignore_errors was true, an exception would occur
if path didn't exist.
üst 7fc2cca7
...@@ -117,18 +117,18 @@ def copytree(src, dst, symlinks=0): ...@@ -117,18 +117,18 @@ def copytree(src, dst, symlinks=0):
if errors: if errors:
raise Error, errors raise Error, errors
def rmtree(path, ignore_errors=0, onerror=None): def rmtree(path, ignore_errors=False, onerror=None):
"""Recursively delete a directory tree. """Recursively delete a directory tree.
If ignore_errors is set, errors are ignored; otherwise, if If ignore_errors is set, errors are ignored; otherwise, if
onerror is set, it is called to handle the error; otherwise, an onerror is set, it is called to handle the error; otherwise, an
exception is raised. exception is raised.
""" """
cmdtuples = [] cmdtuples = []
arg = path
try:
_build_cmdtuple(path, cmdtuples) _build_cmdtuple(path, cmdtuples)
for func, arg in cmdtuples: for func, arg in cmdtuples:
try:
func(arg) func(arg)
except OSError: except OSError:
exc = sys.exc_info() exc = sys.exc_info()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment