Message300305
When I try to re-raise an exception with a __cause__ inside a nested exception, the __context__ of the outer __context__ appears to be reset to None.
e.g.
>>> try:
... try:
... raise Exception('foo')
... except Exception as foo:
... print(foo, foo.__context__, foo.__cause__)
... try:
... raise Exception('bar') from foo
... except Exception as bar:
... print(bar, bar.__context__, bar.__context__.__context__)
... raise foo from bar
... except Exception as foo:
... wat = foo
...
foo None None
bar foo None
>>> print(wat, wat.__context__, wat.__context__.__context__)
foo bar None
>>> print(wat, wat.__cause__, wat.__cause__.__context__)
foo bar None
>>> print(wat, wat.__cause__, wat.__cause__.__cause__)
foo bar foo
here, between "raise foo from bar" and the end, bar.__context__ goes from foo to None. since bar is only raised once, clearly in the context of foo (twice over), I would expect bar.__context__ to stay foo. |
|
Date |
User |
Action |
Args |
2017-08-15 17:43:59 | Christopher Stelma | set | recipients:
+ Christopher Stelma |
2017-08-15 17:43:59 | Christopher Stelma | set | messageid: <1502819039.28.0.810222147268.issue31213@psf.upfronthosting.co.za> |
2017-08-15 17:43:59 | Christopher Stelma | link | issue31213 messages |
2017-08-15 17:43:59 | Christopher Stelma | create | |
|