bpo-44530: Add co_qualname field to PyCodeObject (GH-26941)

This commit is contained in:
Gabriele N. Tornetta 2021-07-07 12:21:51 +01:00 committed by GitHub
parent 32096df0e0
commit 2f180ce2cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 7457 additions and 7444 deletions

View file

@ -1195,7 +1195,7 @@ stack_effect(int opcode, int oparg, int jump)
case CALL_FUNCTION_EX:
return -1 - ((oparg & 0x01) != 0);
case MAKE_FUNCTION:
return -1 - ((oparg & 0x01) != 0) - ((oparg & 0x02) != 0) -
return 0 - ((oparg & 0x01) != 0) - ((oparg & 0x02) != 0) -
((oparg & 0x04) != 0) - ((oparg & 0x08) != 0);
case BUILD_SLICE:
if (oparg == 3)
@ -2138,7 +2138,6 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, Py_ssize_t flags,
ADDOP_I(c, BUILD_TUPLE, co->co_nfreevars);
}
ADDOP_LOAD_CONST(c, (PyObject*)co);
ADDOP_LOAD_CONST(c, qualname);
ADDOP_I(c, MAKE_FUNCTION, flags);
return 1;
}
@ -7389,7 +7388,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
PyObject *consts = NULL;
PyObject *localsplusnames = NULL;
PyObject *localspluskinds = NULL;
PyObject *name = NULL;
names = dict_keys_inorder(c->u->u_names, 0);
if (!names) {
@ -7433,6 +7431,7 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
struct _PyCodeConstructor con = {
.filename = c->c_filename,
.name = c->u->u_name,
.qualname = c->u->u_qualname ? c->u->u_qualname : c->u->u_name,
.flags = flags,
.code = a->a_bytecode,
@ -7475,7 +7474,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
Py_XDECREF(consts);
Py_XDECREF(localsplusnames);
Py_XDECREF(localspluskinds);
Py_XDECREF(name);
return co;
}