mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
Issue #27123: When an exception is raised within the context being
managed by a contextlib.ExitStack() and one of the exit stack generators catches and raises it in a chain, do not re-raise the original exception when exiting, let the new chained one through. This avoids the PEP 479 bug described in issue25782.
This commit is contained in:
commit
881aa38972
3 changed files with 37 additions and 0 deletions
|
@ -105,6 +105,9 @@ class _GeneratorContextManager(ContextDecorator, AbstractContextManager):
|
|||
# raised inside the "with" statement from being suppressed.
|
||||
return exc is not value
|
||||
except RuntimeError as exc:
|
||||
# Don't re-raise the passed in exception. (issue27112)
|
||||
if exc is value:
|
||||
return False
|
||||
# Likewise, avoid suppressing if a StopIteration exception
|
||||
# was passed to throw() and later wrapped into a RuntimeError
|
||||
# (see PEP 479).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue