Nick Coghlan <ncogh...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue32176> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com