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

2010-04-24 Thread rubenlm
New submission from rubenlm : 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 th

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

2010-04-26 Thread rubenlm
rubenlm 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 rmd

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

2010-04-29 Thread rubenlm
rubenlm 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;

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

2010-04-29 Thread rubenlm
rubenlm 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, stat.S_IRW