Skip to content

Commit cd2508f

Browse files
Add some explicit casts to int.
1 parent 09f718f commit cd2508f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Python/compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7399,15 +7399,16 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock) {
73997399
PyObject *k, *v;
74007400
Py_ssize_t pos = 0;
74017401
while (PyDict_Next(c->u->u_cellvars, &pos, &k, &v)) {
7402-
Py_ssize_t cellindex = PyLong_AS_LONG(v);
7402+
assert(PyLong_AS_LONG(v) < INT_MAX);
7403+
int cellindex = (int)PyLong_AS_LONG(v);
74037404
struct instr make_cell = {
74047405
.i_opcode = MAKE_CELL,
74057406
// This will get fixed in offset_derefs().
74067407
.i_oparg = cellindex,
74077408
.i_lineno = -1,
74087409
.i_target = NULL,
74097410
};
7410-
if (insert_instruction(entryblock, pos - 1, &make_cell) < 0) {
7411+
if (insert_instruction(entryblock, (int)(pos - 1), &make_cell) < 0) {
74117412
return -1;
74127413
}
74137414
}

0 commit comments

Comments
 (0)