Nick Coghlan <ncogh...@gmail.com> added the comment:

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)

----------
assignee: ncoghlan -> 
components: +Documentation -Library (Lib)

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37743>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to