[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 dis

[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 emp

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

2010-05-16 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +merwok ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

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

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé 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() directly, for example u

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

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé 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 some use cases in min

[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_IRWXU) # 0700 fu

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

2010-04-29 Thread R. David Murray
R. David Murray 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 improvement over onerror. It

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

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé 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 used *everywhere* i

[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; if os.remove or os.rmdi

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

2010-04-29 Thread Tarek Ziadé
Tarek Ziadé 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 ? You don't know the glob

[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 rmdir fails with "directory not empty". -- ___ Python

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

2010-04-25 Thread R. David Murray
R. David Murray 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 case in which we can't

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

2010-04-25 Thread Brett Cannon
Changes by Brett Cannon : -- assignee: -> tarek nosy: +tarek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[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 the variable "name