This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Rotem Yaari, Yury.Selivanov, georg.brandl, gregory.p.smith, gvanrossum, larry, ncoghlan, oconnor663, serhiy.storchaka, vstinner, yselivanov
Date 2016-06-13.23:03:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465859037.17.0.208706878098.issue25782@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks Serhiy. I've attached a new file (issue27122_broken_cm.py) with a context manager that is deliberately buggy in the same way as contextlib._GeneratorContextManager is currently, so the new test can be made independent of #27122 being fixed (Greg Smith has a pending patch to make that CM well behaved again, which would currently lead to your new test passing for the wrong reasons)

issue27122_broken_cm.py also shows why I think "make it work" is the right answer here - the odd context chaining is tolerated in the case where the interpreter is implicitly setting the exception context, so I believe it should also be tolerated when ExitStack sets the context explicitly. If we "do the right thing" (where "right" = "the same as what the interpreter does") in the setter, then not only ExitStack, but anyone else setting __context__ should automatically benefit from the adjustment.
History
Date User Action Args
2016-06-13 23:03:57ncoghlansetrecipients: + ncoghlan, gvanrossum, georg.brandl, gregory.p.smith, vstinner, larry, Yury.Selivanov, serhiy.storchaka, yselivanov, oconnor663, Rotem Yaari
2016-06-13 23:03:57ncoghlansetmessageid: <1465859037.17.0.208706878098.issue25782@psf.upfronthosting.co.za>
2016-06-13 23:03:57ncoghlanlinkissue25782 messages
2016-06-13 23:03:57ncoghlancreate