What is a complete list of Exceptions that can be thrown by shutil.rmtree
Asked Answered
D

2

16

I am using the rmtree method from shutil in Python (2.7).

What are all possible exceptions that can occur while calling this method?

Dermal answered 11/5, 2011 at 9:38 Comment(2)
Is there anything wrong with reading the docs? shutilOvercompensation
@Jakob I read them, but couldn't figure out from there which errors could be thrown.Dermal
W
12

According to the implementation, you'll have to check OSError. But you can use the argument ignore_errors=True on call to...ignore errors ;) or give a callback onerror that will check the exceptions during the execution of file removal. (cf shutil.rmtree documentation)

Windy answered 11/5, 2011 at 9:48 Comment(0)
D
3

Unless you do something very funky, os.error and OSError

Downcomer answered 11/5, 2011 at 9:49 Comment(2)
os.error is an alias for OSError ;) (docs.python.org/library/os.html#os.error)Anaerobe
@Cédric: interesting, I didn't know that. Curiously, rmtree tries to catch both, in different places. Maybe it's some kind of a historic artifactDowncomer

© 2022 - 2024 — McMap. All rights reserved.