[issue30306] release arguments of contextmanager

Serhiy Storchaka report at bugs.python.org
Tue May 9 05:12:24 EDT 2017


Serhiy Storchaka added the comment:

Wouldn't be better to split _GeneratorContextManager on two classes rather than add a boolean argument? Currently _GeneratorContextManager used  two different functions -- an one-shot context manager and a decorator that recreates context managers.

Proposed patch makes _GeneratorContextManager an one-shot context manager again (it no longer keep references to arguments), and adds _GeneratorContextManagerDecorator which can be used either as an one-shot context manager (references to arguments are removed after use) or as a decorator (in the last case the gen attribute is not created).

----------
keywords: +patch
nosy: +serhiy.storchaka
Added file: http://bugs.python.org/file46852/refactor-contextmanager.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30306>
_______________________________________


More information about the Python-bugs-list mailing list