| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
In both Python 2 and 3, the Exception type is derived from BaseException: The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use Exception). In practice, some libraries provide exception types that do derive directly from BaseException (such as `gevent.Timeout`), and this code should recognize them as valid exception types. As further evidence, Python 2 explicitly states that raised types must be derived from BaseException: exceptions must be old-style classes or derived from BaseException Python 3 is more flexible here, which is why we provide a TypeError case for non-BaseException-derived types. While I'm here, I made that message a little more helpful by including the name of the incompatible type.
| Back | FazBrowse Home | New Git URL |
In both Python 2 and 3, the Exception type is derived from
BaseException:
In practice, some libraries provide exception types that do derive
directly from BaseException (such as gevent.Timeout), and this code
should recognize them as valid exception types.
As further evidence, Python 2 explicitly states that raised types must
be derived from BaseException:
Python 3 is more flexible here, which is why we provide a TypeError case
for non-BaseException-derived types. While I'm here, I made that message
a little more helpful by including the name of the incompatible type.
See also #512