Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a5edf53
Add co_fastlocalnames and co_fastlocalkinds.
ericsnowcurrently May 20, 2021
3cf1539
Populate the fast locals info first.
ericsnowcurrently May 26, 2021
3f11732
Allow co_varnames and friends to be NULL.
ericsnowcurrently May 21, 2021
a492565
Update the import magic number.
ericsnowcurrently May 21, 2021
0ff263e
Regen a couple more files.
ericsnowcurrently May 22, 2021
90f4e8a
Add a NEWS entry.
ericsnowcurrently May 22, 2021
ee10bb3
Fix the arg-is-cell case.
ericsnowcurrently May 24, 2021
861f90c
Use int for counts instead of Py_ssize_t.
ericsnowcurrently May 25, 2021
4d97056
Switch co_fastlocalkinds to a variable length array.
ericsnowcurrently May 25, 2021
f67e7eb
Fix a "smelly" symbol.
ericsnowcurrently May 26, 2021
c5d0ad2
Fix PyFrame_FastToLocals() and PyFrame_LocalsToFast().
ericsnowcurrently May 26, 2021
b9a975c
Fix a typo.
ericsnowcurrently May 26, 2021
3b01a5f
Regen other files.
ericsnowcurrently May 26, 2021
19465f4
Fix the gdb script.
ericsnowcurrently May 26, 2021
93c3568
lint
ericsnowcurrently May 26, 2021
418da97
Expose co_fastlocalnames to Python code.
ericsnowcurrently May 27, 2021
9de74bd
Update the dis docs.
ericsnowcurrently May 27, 2021
e50e286
Use co_fastlocalnames in the dis module.
ericsnowcurrently May 27, 2021
f0fda39
Fix some comments.
ericsnowcurrently May 27, 2021
361ca0a
Drop "inline" from some big functions.
ericsnowcurrently May 27, 2021
bbdaada
Clarify that we only look through the free vars in super_init_without…
ericsnowcurrently May 27, 2021
8c100d9
Clarify about the case where a "fast" arg is also a cell.
ericsnowcurrently May 27, 2021
505536e
Use a private getter function for co_fastlocalnames instead of a prop…
ericsnowcurrently May 27, 2021
885e435
Drop the arg-related flags.
ericsnowcurrently Jun 2, 2021
29e1c2a
Leave the bottom numbers for locals kinds.
ericsnowcurrently Jun 2, 2021
235e4aa
"fastlocal" -> "localsplus"
ericsnowcurrently Jun 2, 2021
13fe60d
Add a note about "locals plus" and variable kinds.
ericsnowcurrently Jun 2, 2021
fba56f5
co._get_localsplusnames() -> co._varname_from_oparg()
ericsnowcurrently Jun 2, 2021
68c7776
Fix the gdb hooks.
ericsnowcurrently Jun 2, 2021
e10e7da
Be more strict about types.
ericsnowcurrently Jun 3, 2021
87cb192
Add a TODO about "_PyCodeConstructor.argcount".
ericsnowcurrently Jun 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Be more strict about types.
  • Loading branch information
ericsnowcurrently committed Jun 3, 2021
commit e10e7da2f93b7b07f33df8531cfb57e80bb9120d
32 changes: 21 additions & 11 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -7230,8 +7230,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
PyObject *localsplusnames = NULL;
_PyLocalsPlusKinds localspluskinds = NULL;
PyObject *name = NULL;
int flags;
int posorkeywordargcount, posonlyargcount, kwonlyargcount;

names = dict_keys_inorder(c->u->u_names, 0);
if (!names) {
Expand All @@ -7241,9 +7239,10 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
goto error;
}

flags = compute_code_flags(c);
if (flags < 0)
int flags = compute_code_flags(c);
if (flags < 0) {
goto error;
}

consts = PyList_AsTuple(constslist); /* PyCode_New requires a tuple */
if (consts == NULL) {
Expand All @@ -7253,9 +7252,23 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
goto error;
}

Py_ssize_t nlocalsplus = PyDict_GET_SIZE(c->u->u_varnames) +
PyDict_GET_SIZE(c->u->u_cellvars) +
PyDict_GET_SIZE(c->u->u_freevars);
assert(c->u->u_posonlyargcount < INT_MAX);
assert(c->u->u_argcount < INT_MAX);
assert(c->u->u_kwonlyargcount < INT_MAX);
int posonlyargcount = (int)c->u->u_posonlyargcount;
int posorkwargcount = (int)c->u->u_argcount;
assert(INT_MAX - posonlyargcount - posorkwargcount > 0);
int kwonlyargcount = (int)c->u->u_kwonlyargcount;

Py_ssize_t nlocals = PyDict_GET_SIZE(c->u->u_varnames);
Py_ssize_t ncellvars = PyDict_GET_SIZE(c->u->u_cellvars);
Py_ssize_t nfreevars = PyDict_GET_SIZE(c->u->u_freevars);
assert(nlocals < INT_MAX);
assert(ncellvars < INT_MAX);
assert(nfreevars < INT_MAX);
assert(INT_MAX - nlocals - ncellvars - nfreevars > 0);
int nlocalsplus = (int)nlocals + (int)ncellvars + (int)nfreevars;

localsplusnames = PyTuple_New(nlocalsplus);
if (localsplusnames == NULL) {
goto error;
Expand All @@ -7265,9 +7278,6 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
}
compute_localsplus_info(c, localsplusnames, localspluskinds);

posonlyargcount = Py_SAFE_DOWNCAST(c->u->u_posonlyargcount, Py_ssize_t, int);
posorkeywordargcount = Py_SAFE_DOWNCAST(c->u->u_argcount, Py_ssize_t, int);
kwonlyargcount = Py_SAFE_DOWNCAST(c->u->u_kwonlyargcount, Py_ssize_t, int);
struct _PyCodeConstructor con = {
.filename = c->c_filename,
.name = c->u->u_name,
Expand All @@ -7283,7 +7293,7 @@ makecode(struct compiler *c, struct assembler *a, PyObject *constslist,
.localsplusnames = localsplusnames,
.localspluskinds = localspluskinds,

.argcount = posonlyargcount + posorkeywordargcount,
.argcount = posonlyargcount + posorkwargcount,
.posonlyargcount = posonlyargcount,
.kwonlyargcount = kwonlyargcount,

Expand Down