New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document BaseException in favour of bare except in error tutorial #85748
Comments
What a problem do you try to solve? What is wrong with the current documentation? |
it seems odd to document digging around in sys.exc_info() in favour of the more ergonomic syntax to do the same thing |
PEP-8 discourages the use of bare except. |
It is a tutorial. The purpose of this part is documenting the bare except clause. It cannot be done without using a bare except in example. There is nothing wrong with a bare except if it used properly (e.g. if the caught exception is reraised). In any case "except BaseException" is not any better, because it is equivalent to a bare except. Note also that PR 21917 introduces an error: instead of printing the type of exception it prints the stringified exception itself (in some case it is an empty string). |
The purpose of this tutorial section is to document how to catch all types of exceptions and extract the type and value. When this is required, `BaseException as err:` is the preferred approach. This document still mentions the alternative approach so that readers will know what it means when they encounter it, and know to upgrade it to the py2.4+ syntax |
Serhiy/Terry: Is further discussion needed? Can this be closed, or should the proposed PR be applied (after resolving any issues)? |
Thanks, Thomas! ✨ 🍰 ✨ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: