]> granicus.if.org Git - python/commit
[3.6] bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError ...
authorMariatta <Mariatta@users.noreply.github.com>
Thu, 13 Apr 2017 09:50:21 +0000 (02:50 -0700)
committerGitHub <noreply@github.com>
Thu, 13 Apr 2017 09:50:21 +0000 (02:50 -0700)
commit9b409ff41ceb2d7ea7e8d25a7bbf5eb7d46625f3
tree4af736ab237728f15ea85e6e2767a19d24be6e6d
parentbd1173f202f5a3990063d980368e7ad1edc9b5b5
[3.6] bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError (GH-949) (#1105)

contextlib._GeneratorContextManager.__exit__ includes a special case to deal with
PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context
manager body.

Previously this check was too permissive, and undid one level of chaining on *all*
RuntimeError instances, not just those that wrapped a StopIteration instance.
(cherry picked from commit 00c75e9a45ff0366c185e9e8a2e23af5a35481b0)
Lib/contextlib.py
Lib/test/test_contextlib.py
Misc/NEWS