Treat exceptions as normal variables properly - #150
victorjzsun wants to merge 3 commits into
Conversation
| try: | ||
| a = RuntimeError("A") | ||
| raise a | ||
| except b.__class__ as e: |
There was a problem hiding this comment.
it's not entirely clear to me what this part is for, mind elaborate?
There was a problem hiding this comment.
It's using a merge_stack_items on an actual error class from raise_args and a stack item containing b. Merging two SymbolWithCustomValue's (will be) done in simple test, this one tests merging a SymbolWithCustomValue with a CustomValue.
The second except is unnecessary since it's similar to the outer except.
There was a problem hiding this comment.
Consider breaking this test down to smaller ones, ideally with one-except, and please add proper comments. In any case, I'd want to avoid tests from which readers cannot see the intent at first glance.
| @@ -0,0 +1,84 @@ | |||
| import pytest | |||
There was a problem hiding this comment.
Can we add some tests in which exceptions have sources? e.g.
b = ... # a string
a = ImportError(b)
|
some test errors seem to be related to pdm. maybe try updating its version and try again? |
| class CustomException(Exception): | ||
| pass | ||
|
|
||
| a = ImportError("A") |
There was a problem hiding this comment.
I think ImportError("A") is equivalent to ImportError() in our case? In other words, "A" and "B" are merely distractions, I'd probably remove them from all tests.
Also, having print(a) doesn't seem very useful either.
Fixes #147
Use
SymbolWithCustomValueStackItemclass to allow exceptions to be treated as normal variables.