]> granicus.if.org Git - python/commit
[3.5] bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError ...
authorMariatta <Mariatta@users.noreply.github.com>
Thu, 13 Apr 2017 10:14:53 +0000 (03:14 -0700)
committerGitHub <noreply@github.com>
Thu, 13 Apr 2017 10:14:53 +0000 (03:14 -0700)
commit4d015a40a7b9c3c1b8cfbe81453187d700a43163
treecafa37d8b357968486792e40e9625163e0c45aea
parentc0f4240fac397e1cdd1ee202fc1ce6eb23037d06
[3.5] bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError (GH-949) (#1107)

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