[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2013-04-07 Thread R. David Murray
R. David Murray added the comment: I think this patch looks good, but it needs a documentation update to go with it. Do you want to work on that, Andrew? It also seems as though there's no bug that it is practical to fix here, so I'm changing this to a pure enhancement request. If anyone

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2013-03-18 Thread Andrew Gorcester
Andrew Gorcester added the comment: Product of the #pycon 2013 sprint with r.david.murray's assistance. This implements the list of results as per tarek's suggested 1/ behavior in cases where ignore_errors=True. Parameters accepted are not changed; return value is changed from None to an

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-05-16 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8523 ___ ___ Python-bugs-list mailing

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé ziade.ta...@gmail.com added the comment: The whole error handling in rmtree strikes me as something that cannot be used efficiently. (see also #7969). How can you decide in an isolated function, that can be called anywhere in the tree you want to remove, the proper thing to do ?

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread rubenlm
rubenlm ru...@libhertz.com added the comment: Do you really need the global status? I wrote an onerror that seems to works fine after I modified rmtree with the return suggested by r.david.murray. It assumes that: if os.listdir fails: the user doesn't have read permissions in the dir; if

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé ziade.ta...@gmail.com added the comment: /1 seems ok to me but to make use of the global status it provides the user must write a somewhat complex recovery code. The onerror() code you did is as complex as a global function working with a sequence returned by rmtree, since it is

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Well, I don't think removing the current onerror support is a viable option for backward compatibility reasons, so we might as well fix it. I agree that (2) sounds tricky to get reliably right, while I don't see how (1) is an

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread rubenlm
rubenlm ru...@libhertz.com added the comment: Here is my current error handler: def handleRmtreeError(func, path, exc): excvalue = exc[1] if excvalue.errno == errno.EACCES: if func in (os.rmdir, os.remove): parentpath = path.rpartition('/')[0] os.chmod(parentpath,

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé ziade.ta...@gmail.com added the comment: Well, I don't think removing the current onerror support is a viable option for backward compatibility reasons, so we might as well fix it. The options could be deprecated since the new behavior would *return* errors. Do you have

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé ziade.ta...@gmail.com added the comment: Looking at your example rubenlm, it appears like a case that is missing in rmtree(). You are trying to chmod your tree if a file in there cannot be removed because of the permissions. This sounds like something we need to add in rmtree()

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-26 Thread rubenlm
rubenlm ru...@libhertz.com added the comment: Your solution sounds fine to me. Currently we don't get a NameError because names is set to [] before the try. What happens is that the for is skipped and later rmdir fails with directory not empty. --

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-25 Thread Brett Cannon
Changes by Brett Cannon br...@python.org: -- assignee: - tarek nosy: +tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8523 ___ ___

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-25 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: If solution 1 is acceptable in the general case, then I think a better fix would look like this: try: names = os.listdir(path) except os.error, err: onerror(os.listdir, path, sys.exc_info()) return That is, this is another

[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-24 Thread rubenlm
New submission from rubenlm ru...@libhertz.com: The code that lists directory contents in rmtree is: try: names = os.listdir(path) except os.error, err: onerror(os.listdir, path, sys.exc_info()) If there is an error there is nothing the onerror function can do to fix the problem because