[issue25683] __context__ for yields inside except clause
Nathaniel Smith
report at bugs.python.org
Fri Feb 17 06:55:09 EST 2017
Nathaniel Smith added the comment:
I disagree with the stated reason for closing this, because in general, implicit context chaining doesn't care about where the exception was instantiated, only where it was raised. For example:
-----
err = ValueError()
try:
raise KeyError
except Exception:
raise err
-----
Prints:
-----
Traceback (most recent call last):
File "/tmp/bar.py", line 3, in <module>
raise KeyError
KeyError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/bar.py", line 5, in <module>
raise err
ValueError
-----
I would expect 'gen.throw(OBJ)' to be equivalent to doing 'raise OBJ' inside the generator, and raise does set __context__.
----------
nosy: +njs
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25683>
_______________________________________
More information about the Python-bugs-list
mailing list