14

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

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

Peter Smit
  • 27,696
  • 33
  • 111
  • 170

2 Answers2

11

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)

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
3

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

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412