Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8e3221

Browse files
committed
Issue #9566, #19617: Fix more compiler warnings in compile.c on Windows 64-bit
1 parent 5323fb0 commit f8e3221

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

Python/compile.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ struct compiler_unit {
120120

121121
PyObject *u_private; /* for private name mangling */
122122

123-
int u_argcount; /* number of arguments for block */
124-
int u_kwonlyargcount; /* number of keyword only arguments for block */
123+
Py_ssize_t u_argcount; /* number of arguments for block */
124+
Py_ssize_t u_kwonlyargcount; /* number of keyword only arguments for block */
125125
/* Pointer to the most recently allocated block. By following b_list
126126
members, you can reach all early allocated blocks. */
127127
basicblock *u_blocks;
@@ -170,7 +170,7 @@ static basicblock *compiler_new_block(struct compiler *);
170170
static int compiler_next_instr(struct compiler *, basicblock *);
171171
static int compiler_addop(struct compiler *, int);
172172
static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *);
173-
static int compiler_addop_i(struct compiler *, Py_ssize_t, Py_ssize_t);
173+
static int compiler_addop_i(struct compiler *, int, Py_ssize_t);
174174
static int compiler_addop_j(struct compiler *, int, basicblock *, int);
175175
static basicblock *compiler_use_new_block(struct compiler *);
176176
static int compiler_error(struct compiler *, const char *);
@@ -1074,7 +1074,7 @@ compiler_addop(struct compiler *c, int opcode)
10741074
return 1;
10751075
}
10761076

1077-
static int
1077+
static Py_ssize_t
10781078
compiler_add_o(struct compiler *c, PyObject *dict, PyObject *o)
10791079
{
10801080
PyObject *t, *v;
@@ -1176,22 +1176,22 @@ compiler_addop_name(struct compiler *c, int opcode, PyObject *dict,
11761176
*/
11771177

11781178
static int
1179-
compiler_addop_i(struct compiler *c, Py_ssize_t opcode, Py_ssize_t oparg)
1179+
compiler_addop_i(struct compiler *c, int opcode, Py_ssize_t oparg)
11801180
{
11811181
struct instr *i;
11821182
int off;
11831183

11841184
/* Integer arguments are limit to 16-bit. There is an extension for 32-bit
11851185
integer arguments. */
1186-
assert((-2147483647-1) <= opcode);
1187-
assert(opcode <= 2147483647);
1186+
assert((-2147483647-1) <= oparg);
1187+
assert(oparg <= 2147483647);
11881188

11891189
off = compiler_next_instr(c, c->u->u_curblock);
11901190
if (off < 0)
11911191
return 0;
11921192
i = &c->u->u_curblock->b_instr[off];
1193-
i->i_opcode = Py_SAFE_DOWNCAST(opcode, Py_ssize_t, int);
1194-
i->i_oparg = oparg;
1193+
i->i_opcode = opcode;
1194+
i->i_oparg = Py_SAFE_DOWNCAST(oparg, Py_ssize_t, int);
11951195
i->i_hasarg = 1;
11961196
compiler_set_lineno(c, off);
11971197
return 1;
@@ -4213,6 +4213,7 @@ makecode(struct compiler *c, struct assembler *a)
42134213
Py_ssize_t nlocals;
42144214
int nlocals_int;
42154215
int flags;
4216+
int argcount, kwonlyargcount;
42164217

42174218
tmp = dict_keys_inorder(c->u->u_consts, 0);
42184219
if (!tmp)
@@ -4250,7 +4251,9 @@ makecode(struct compiler *c, struct assembler *a)
42504251
Py_DECREF(consts);
42514252
consts = tmp;
42524253

4253-
co = PyCode_New(c->u->u_argcount, c->u->u_kwonlyargcount,
4254+
argcount = Py_SAFE_DOWNCAST(c->u->u_argcount, Py_ssize_t, int);
4255+
kwonlyargcount = Py_SAFE_DOWNCAST(c->u->u_kwonlyargcount, Py_ssize_t, int);
4256+
co = PyCode_New(argcount, kwonlyargcount,
42544257
nlocals_int, stackdepth(c), flags,
42554258
bytecode, consts, names, varnames,
42564259
freevars, cellvars,

0 commit comments

Comments
 (0)