[Python-ideas] __enter__ and __exit__ on generators

Michael Selik michael.selik at gmail.com
Tue Jul 5 22:40:04 EDT 2016

On Tue, Jul 5, 2016 at 10:31 PM Nick Coghlan <ncoghlan at gmail.com> wrote:

> It does occur to me that it might be worth customising the error
> reported, though - it's currently genuinely non-obvious why they don't
> implement the protocol, but it might be clearer if the error was
> "TypeError: generator requires 'contextlib.contextmanager' or
> 'contextlib.closing' to support context management"

+1 for error messages that explain how to solve the problem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160706/9612671d/attachment-0001.html>

More information about the Python-ideas mailing list