[issue32176] Zero argument super is broken in 3.6 for methods with a hacked __class__ cell

Nick Coghlan report at bugs.python.org
Fri Dec 1 23:16:57 EST 2017


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Given that, I'd say the way to cleanest way to fix this would be to remove these lines from "compute_code_flags" in compile.c:

    if (!PyDict_GET_SIZE(c->u->u_freevars) &&
        !PyDict_GET_SIZE(c->u->u_cellvars)) {
        flags |= CO_NOFREE;
    }

and replace them with a check like the following in PyCode_New just after we ensure the Unicode string for the filename is ready:

    if (!PyTuple_GET_SIZE(freevars) &&
        !PyTuple_GET_SIZE(cellvars)) {
        flags |= CO_NOFREE;
    }

That way CO_NOFREE will be set only when appropriate regardless of how the code object is created, rather than relying on the caller to set it correctly.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32176>
_______________________________________


More information about the Python-bugs-list mailing list