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 docs@python, ezio.melotti, ncoghlan, terry.reedy, yak
Date 2012-01-22.06:58:15
SpamBayes Score 0.0010965992
Marked as misclassified No
Message-id <>
Generators deliberately don't support the context management protocol. This is so that they raise an explicit TypeError or AttributeError (pointing out that __exit__ is missing) if you leave out the @contextmanager decorator when you're using a generator to write an actual context manager.

Generators supporting the context management protocol natively would turn that into a far more subtle (and confusing) error: your code would silently fail to invoke the generator body.

Ensuring this common error remains easy to detect is far more important than making it easier to invoke close() on a generator object (particularly when contextlib.closing() already makes that very easy).
Date User Action Args
2012-01-22 06:58:17ncoghlansetrecipients: + ncoghlan, terry.reedy, ezio.melotti, docs@python, yak
2012-01-22 06:58:17ncoghlansetmessageid: <>
2012-01-22 06:58:16ncoghlanlinkissue13814 messages
2012-01-22 06:58:15ncoghlancreate