Skip to content
Snippets Groups Projects

Catch correct exception from shutil.rmtree [bst-1.2]

Merged Valentin David requested to merge valentindavid/rmtree_oserror-1.2 into bst-1.2
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
  • 26d48cc9
    Python documentation is not clear on what shutil.rmtree is supposed to
    raise. However from the source code, it is obvious that OSError are
    raised, but never shutil.Error.
    
    It is not easy to test in normal condition because issues happen
    usually in combination with a FUSE filesystem, a probably a race
    condition where `fstatat` returns an error just before the filesystem
    being unmounted.
    
    Fixes #153.
+ 1
1
@@ -679,7 +679,7 @@ def _force_rmtree(rootpath, **kwargs):
try:
shutil.rmtree(rootpath, **kwargs)
except shutil.Error as e:
except OSError as e:
raise UtilError("Failed to remove cache directory '{}': {}"
.format(rootpath, e))
Loading