summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 0a18148..9118d12 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -7187,15 +7187,13 @@ merge_const_one(struct compiler *c, PyObject **obj)
}
// This is in codeobject.c.
-extern void _Py_set_localsplus_info(int, PyObject *, _PyLocalsPlusKind,
- PyObject *, _PyLocalsPlusKinds);
+extern void _Py_set_localsplus_info(int, PyObject *, unsigned char,
+ PyObject *, PyObject *);
static void
compute_localsplus_info(struct compiler *c, int nlocalsplus,
- PyObject *names, _PyLocalsPlusKinds kinds)
+ PyObject *names, PyObject *kinds)
{
- assert(PyTuple_GET_SIZE(names) == nlocalsplus);
-
PyObject *k, *v;
Py_ssize_t pos = 0;
while (PyDict_Next(c->u->u_varnames, &pos, &k, &v)) {
@@ -7203,7 +7201,7 @@ compute_localsplus_info(struct compiler *c, int nlocalsplus,
assert(offset >= 0);
assert(offset < nlocalsplus);
// For now we do not distinguish arg kinds.
- _PyLocalsPlusKind kind = CO_FAST_LOCAL;
+ _PyLocals_Kind kind = CO_FAST_LOCAL;
if (PyDict_GetItem(c->u->u_cellvars, k) != NULL) {
kind |= CO_FAST_CELL;
}
@@ -7245,7 +7243,7 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
PyObject *names = NULL;
PyObject *consts = NULL;
PyObject *localsplusnames = NULL;
- _PyLocalsPlusKinds localspluskinds = NULL;
+ PyObject *localspluskinds = NULL;
PyObject *name = NULL;
names = dict_keys_inorder(c->u->u_names, 0);
@@ -7281,7 +7279,8 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
if (localsplusnames == NULL) {
goto error;
}
- if (_PyCode_InitLocalsPlusKinds(nlocalsplus, &localspluskinds) < 0) {
+ localspluskinds = PyBytes_FromStringAndSize(NULL, nlocalsplus);
+ if (localspluskinds == NULL) {
goto error;
}
compute_localsplus_info(c, nlocalsplus, localsplusnames, localspluskinds);
@@ -7315,7 +7314,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
}
if (!merge_const_one(c, &localsplusnames)) {
- _PyCode_ClearLocalsPlusKinds(con.localspluskinds);
goto error;
}
con.localsplusnames = localsplusnames;
@@ -7325,13 +7323,11 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
goto error;
}
- localspluskinds = NULL; // This keeps it from getting freed below.
-
error:
Py_XDECREF(names);
Py_XDECREF(consts);
Py_XDECREF(localsplusnames);
- _PyCode_ClearLocalsPlusKinds(localspluskinds);
+ Py_XDECREF(localspluskinds);
Py_XDECREF(name);
return co;
}