Serhiy Storchaka <[email protected]> added the comment:
I tried the following code:
def g():
yield 1
raise
yield 2
i = g()
try:
1/0
except:
next(i)
next(i)
Currently it raises:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
With PR 1773 applied it raises:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "<stdin>", line 3, in g
RuntimeError: No active exception to reraise
And this looks more correct.
But if replace raise with print(sys.exc_info()) the patched and unpatched
interpreters both print:
(<class 'ZeroDivisionError'>, ZeroDivisionError('division by zero',),
<traceback object at 0x7f61d9ed1448>)
Is it correct that sys.exc_info() return an exception while raise can't reraise
it?
----------
versions: +Python 3.7 -Python 3.4, Python 3.5
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue25612>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com