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 Nan Wu, brett.cannon, gvanrossum, jstasiak, martin.panter, ncoghlan, rhettinger
Date 2016-03-19.12:43:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
* the ABC should have a structural __issubclass__ check looking for __enter__ and __exit__ methods

* I agree with making __exit__ abstract (if you don't define it, you don't need a context manager), but does __enter__ need to be abstract? The "return self" default is a good one in many cases where the resource is acquired in __new__ or __init__.

* the docs for the ABC are potentially confusing, as they describe what the default implementation does, without making it clear that it's only the default implementation and *permitted* return behaviour is more flexible than that.

* I'd prefer not to have contextlib depend on typing, so the generic type definition should probably be in the typing module (similar to the abc-vs-type split for collections). That should also make backporting easier - the ABC can go back via contextlib2, while the generic type can go back via the comment-based typehinting variant
Date User Action Args
2016-03-19 12:43:37ncoghlansetrecipients: + ncoghlan, gvanrossum, brett.cannon, rhettinger, martin.panter, jstasiak, Nan Wu
2016-03-19 12:43:37ncoghlansetmessageid: <>
2016-03-19 12:43:37ncoghlanlinkissue25609 messages
2016-03-19 12:43:37ncoghlancreate