Skip to content

Commit

Permalink
Handle exceptions in hookwrapper post stage (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnikulin authored and a committed Jun 30, 2020
1 parent 0a678db commit f2ee87a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pluggy/callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ def _multicall(hook_impls, caller_kwargs, firstresult=False):
# run all wrapper post-yield blocks
for gen in reversed(teardowns):
try:
gen.send(outcome)
_raise_wrapfail(gen, "has second yield")
except StopIteration:
pass
try:
gen.send(outcome)
_raise_wrapfail(gen, "has second yield")
except StopIteration:
pass
finally:
# Exception is risen only if generator
# suppresses GeneratorExit exception and yield
# so _raise_wrapfail above is necessary
gen.close()
except BaseException:
outcome._excinfo = sys.exc_info()

return outcome.get_result()

0 comments on commit f2ee87a

Please sign in to comment.