]> granicus.if.org Git - python/commit
bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError (GH-949)
authorsvelankar <siddharth.velankar@gmail.com>
Tue, 11 Apr 2017 09:11:13 +0000 (05:11 -0400)
committerNick Coghlan <ncoghlan@gmail.com>
Tue, 11 Apr 2017 09:11:13 +0000 (19:11 +1000)
commit00c75e9a45ff0366c185e9e8a2e23af5a35481b0
tree15be21a9abc45df371cfccdf11cb25f3e82a1594
parent6fab78e9027f9ebd6414995580781b480433e595
bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError (GH-949)

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.
Lib/contextlib.py
Lib/test/test_contextlib.py
Misc/NEWS