Author serhiy.storchaka
Recipients asvetlov, benjamin.peterson, brett.cannon, emptysquare, larry, martin.panter, ncoghlan, njs, pitrou, serhiy.storchaka, vstinner, yselivanov
Date 2017-10-11.08:31:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507710688.7.0.213398074469.issue25612@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2017-10-11 08:31:28serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, ncoghlan, pitrou, vstinner, larry, benjamin.peterson, njs, asvetlov, martin.panter, yselivanov, emptysquare
2017-10-11 08:31:28serhiy.storchakasetmessageid: <1507710688.7.0.213398074469.issue25612@psf.upfronthosting.co.za>
2017-10-11 08:31:28serhiy.storchakalinkissue25612 messages
2017-10-11 08:31:28serhiy.storchakacreate