mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
Fix contextlib.nested to cope with exit methods raising and handling exceptions
This commit is contained in:
parent
27ec1a773c
commit
da2268feec
3 changed files with 33 additions and 1 deletions
|
@ -127,7 +127,10 @@ def nested(*contexts):
|
|||
except:
|
||||
exc = sys.exc_info()
|
||||
if exc != (None, None, None):
|
||||
raise
|
||||
# Don't rely on sys.exc_info() still containing
|
||||
# the right information. Another exception may
|
||||
# have been raised and caught by an exit method
|
||||
raise exc[0], exc[1], exc[2]
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue