[Python-Dev] Please reconsider PEP 479.

Chris Angelico rosuav at gmail.com
Thu Nov 27 01:03:05 CET 2014


On Thu, Nov 27, 2014 at 9:53 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> The implicit stop decorator would then check the flags on the code object
> attached to the passed in function. If GENERATOR wasn't set, that would be
> an immediate ValueError, while if EXPLICIT_STOP wasn't set, the generator
> function would be passed through unmodified. However, if EXPLICIT_STOP *was*
> set, the generator function would be replaced by a *new* generator function
> with a *new* code object, where the only change was to clear the
> EXPLICIT_STOP flag.

Is it possible to replace the code object without replacing the
function? Imagine if you have multiple decorators, one of which
retains a reference to the function and then this one which replaces
it - the order of decoration would be critical. OTOH, I don't know
that anyone would retain references to __code__.

ChrisA


More information about the Python-Dev mailing list