Skip to content
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

Use BaseException in raise_() #515

Merged
merged 1 commit into from
Oct 24, 2019

Commits on Oct 18, 2019

  1. Use BaseException in raise_()

    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.
    jparise committed Oct 18, 2019
    Configuration menu
    Copy the full SHA
    51509ad View commit details
    Browse the repository at this point in the history