Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Open
Description
Documentation
When I looked at the docs of theshutil module, I noticed that it doesn't mention thatshutil.Error is a subclass ofOSError. runningshutil.Error.mro() reveals that indeedshutil.Error subclassesOSError and it can also be seen in thecode. I think it would be nice to document this fact, so I know that if I do multiple operations which could raise other subclasses ofOSError likeshutil.copy, then I can use:
try: ...# Use shutil.copytree which raises shutil.Error and/or shutil.copy/shutil.copy2 which raises OSErrorexceptOSErrorase: ...# Handle any error that occured.
instead of:
try: ...except (OSError,shutil.Error)ase:# The docs don't mention that shutil.Error and OSError are related, so I need to catch both of them ...
If it's intentionally not documented since it's an implementation detail, then I still think the docs should mention that and say that it could change, and users shouldn't rely onshutil.Error being a subclass ofOSError.
Metadata
Metadata
Assignees
Projects
Status
Todo