Message304117
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? |
|
Date |
User |
Action |
Args |
2017-10-11 08:31:28 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, brett.cannon, ncoghlan, pitrou, vstinner, larry, benjamin.peterson, njs, asvetlov, martin.panter, yselivanov, emptysquare |
2017-10-11 08:31:28 | serhiy.storchaka | set | messageid: <1507710688.7.0.213398074469.issue25612@psf.upfronthosting.co.za> |
2017-10-11 08:31:28 | serhiy.storchaka | link | issue25612 messages |
2017-10-11 08:31:28 | serhiy.storchaka | create | |
|