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 Albert.Zeyer, Alexander.Jones, DLitz, Martin Blais, blais, daniel.urban, eric.araujo, georg.brandl, giampaolo.rodola, hniksic, michael.foord, ncoghlan, piotr.dobrogost, pitrou, r.david.murray, rhettinger, vstinner
Date 2017-11-10.01:35:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Reopening this based on several years of additional experience with context managers since I wrote when originally closing it.

The version I'm now interested in adding is the one from - rather than being completely without behaviour, the null context manager should accept the value to be returned from the call to __enter__ as an optional constructor parameter (defaulting to None). That allows even context managers that return a value from __enter__ to be made optional in a relatively obvious way that doesn't involve fundamentally rearranging the code.

I think the overhead argument against the use of ExitStack() for this purpose also has merit (so I'd be curious to see relative performance numbers collected with perf), but it's not my main motive for changing my mind.
Date User Action Args
2017-11-10 01:35:43ncoghlansetrecipients: + ncoghlan, georg.brandl, rhettinger, blais, pitrou, vstinner, giampaolo.rodola, hniksic, eric.araujo, r.david.murray, michael.foord, daniel.urban, Albert.Zeyer, piotr.dobrogost, Alexander.Jones, DLitz, Martin Blais
2017-11-10 01:35:42ncoghlansetmessageid: <>
2017-11-10 01:35:42ncoghlanlinkissue10049 messages
2017-11-10 01:35:40ncoghlancreate