Message108877
Patch to add a ContextDecorator class to contextlib. This allows context managers that inherit from ContextDecorator (including using it as a mixin) to be used as decorators as well as context managers.
Context managers inheriting from ContextDecorator still have to implement __enter__ and __exit__ as normal. As the decorator behaviour is implemented using a with statement __exit__ retains its optional exception handling even when used as a decorator.
In addition contextlib.GeneratorContextManager, used to implement contextlib.contextmanager, inherits from ContextDecorator. Context managers created with contextlib.contextmanager can therefore be used as decorators too. |
|
Date |
User |
Action |
Args |
2010-06-28 22:58:19 | michael.foord | set | recipients:
+ michael.foord, ncoghlan |
2010-06-28 22:58:18 | michael.foord | set | messageid: <1277765898.65.0.314299135702.issue9110@psf.upfronthosting.co.za> |
2010-06-28 22:58:17 | michael.foord | link | issue9110 messages |
2010-06-28 22:58:16 | michael.foord | create | |
|