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

exception inheritance no longer works in Python 3 #4

Open
gjb1002 opened this issue May 8, 2019 · 3 comments
Open

exception inheritance no longer works in Python 3 #4

gjb1002 opened this issue May 8, 2019 · 3 comments

Comments

@gjb1002
Copy link
Contributor

gjb1002 commented May 8, 2019

The main reason is that Python 3 does not allow catching exceptions that don't inherit from BaseException. In Python 2 you could catch anything at all.

This caused the failure of TextTest self-tests NoSuchUser and NoSuchSender. Have fixed these for now by hacking in the mock file, should be reverted when this is fixed.

@gjb1002
Copy link
Contributor Author

gjb1002 commented Jul 31, 2019

In total responsible for 8 failing TextTest self-tests, including 3 that hang under ec2cloud.

@gjb1002
Copy link
Contributor Author

gjb1002 commented Aug 2, 2019

Basic problem is the situation when you have two levels of exception in the intercepted module.

class MyBaseException(RuntimeError):
    pass

class MyDerivedException(MyBaseException):
    pass

Capturemock represents this as

<-PYT:raise MyDerivedException(MyBaseException, RuntimeError)("error msg")
but this leads to a multiple inheritance situation and crucially MyBaseException ends up not being derived from RuntimeError, meaning if the code catches it failure will result.

Perhaps it needs to say

<-PYT:raise MyDerivedException(MyBaseException(RuntimeError))("error msg")

but my attempts to make that work with name handlers etc didn't work so well.

@gjb1002
Copy link
Contributor Author

gjb1002 commented Aug 2, 2019

All failing self-tests have either been worked around or disabled though (not all were this issue in the end, in some cases exceptions had just been renamed).

In any case this is no longer critical there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant