Message262044
* 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:37 | ncoghlan | set | recipients:
+ ncoghlan, gvanrossum, brett.cannon, rhettinger, martin.panter, jstasiak, Nan Wu |
2016-03-19 12:43:37 | ncoghlan | set | messageid: <1458391417.78.0.301046712667.issue25609@psf.upfronthosting.co.za> |
2016-03-19 12:43:37 | ncoghlan | link | issue25609 messages |
2016-03-19 12:43:37 | ncoghlan | create | |
|