pytest-dev / pluggy

A minimalist production ready plugin system
https://pluggy.readthedocs.io/en/latest/
MIT License
1.31k stars 126 forks source link

StopIteration passtrough not handled correctly #544

Closed RonnyPfannschmidt closed 2 weeks ago

RonnyPfannschmidt commented 1 month ago

cpython impl ref in contextmanager

a test in one of my testsuites failed with a StopIteration as exception

this ran into issues as new style hook wrappers dont manage the RuntimeError of stopIteration


>>> def mygen(): yield
... 
>>> gen = mygen()
>>> next(gen)
>>> e = StopIteration()
>>> try:
...   gen.throw(e)
... except Exception as err:
...   runtime = err
... 
>>> runtime
RuntimeError('generator raised StopIteration')
>>> runtime.
runtime.add_note(        runtime.args             runtime.with_traceback(  
>>> runtime.a
runtime.add_note(  runtime.args       
>>> runtime.args
('generator raised StopIteration',)
>>> runtime.__cause__
StopIteration()
>>> runtime.__cause__ is e
True
>>>