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 Antony.Lee, ncoghlan
Date 2019-09-03.08:25:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567499136.05.0.113481700024.issue37743@roundup.psfhosted.org>
In-reply-to
Content
This is a documentation bug, as the current behaviour is as intended, but the documented equivalence doesn't hold for generator functions: for a generator function, the CM will only be applied when the generator is instantiated, whereas the inline context manager version will be held open until the generator is closed or destroyed.

That said, an approach similar to the one discussed in #37398 could also be applied, here, with a separate "ContextDecorator.generator()" class method added to give the "wrapped yield from" behaviour. If anyone is interested in pursuing that, it can be filed as a separate enhancement issue (leaving this bug to cover the fact that the existing documentation is only accurate for regular synchronous functions)
History
Date User Action Args
2019-09-03 08:25:36ncoghlansetrecipients: + ncoghlan, Antony.Lee
2019-09-03 08:25:36ncoghlansetmessageid: <1567499136.05.0.113481700024.issue37743@roundup.psfhosted.org>
2019-09-03 08:25:36ncoghlanlinkissue37743 messages
2019-09-03 08:25:35ncoghlancreate