Fixes loop variables to be the same types as their limit (GH-120958)

This commit is contained in:
Steve Dower 2024-06-24 17:11:47 +01:00 committed by GitHub
parent 2e157851e3
commit e731554337
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 26 additions and 26 deletions

View file

@ -521,7 +521,7 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
static PyObject*
make_const_tuple(asdl_expr_seq *elts)
{
for (int i = 0; i < asdl_seq_LEN(elts); i++) {
for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) {
expr_ty e = (expr_ty)asdl_seq_GET(elts, i);
if (e->kind != Constant_kind) {
return NULL;
@ -533,7 +533,7 @@ make_const_tuple(asdl_expr_seq *elts)
return NULL;
}
for (int i = 0; i < asdl_seq_LEN(elts); i++) {
for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) {
expr_ty e = (expr_ty)asdl_seq_GET(elts, i);
PyObject *v = e->v.Constant.value;
PyTuple_SET_ITEM(newval, i, Py_NewRef(v));
@ -650,7 +650,7 @@ static int astfold_type_param(type_param_ty node_, PyArena *ctx_, _PyASTOptimize
return 0;
#define CALL_SEQ(FUNC, TYPE, ARG) { \
int i; \
Py_ssize_t i; \
asdl_ ## TYPE ## _seq *seq = (ARG); /* avoid variable capture */ \
for (i = 0; i < asdl_seq_LEN(seq); i++) { \
TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, i); \

View file

@ -5109,7 +5109,7 @@ compiler_call_simple_kw_helper(struct compiler *c, location loc,
if (names == NULL) {
return ERROR;
}
for (int i = 0; i < nkwelts; i++) {
for (Py_ssize_t i = 0; i < nkwelts; i++) {
keyword_ty kw = asdl_seq_GET(keywords, i);
PyTuple_SET_ITEM(names, i, Py_NewRef(kw->arg));
}

View file

@ -2095,7 +2095,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts)
/* now index_map[i] == i if consts[i] is used, -1 otherwise */
/* condense consts */
Py_ssize_t n_used_consts = 0;
for (int i = 0; i < nconsts; i++) {
for (Py_ssize_t i = 0; i < nconsts; i++) {
if (index_map[i] != -1) {
assert(index_map[i] == i);
index_map[n_used_consts++] = index_map[i];

View file

@ -8,7 +8,7 @@
static int
future_check_features(_PyFutureFeatures *ff, stmt_ty s, PyObject *filename)
{
int i;
Py_ssize_t i;
assert(s->kind == ImportFrom_kind);

View file

@ -2070,7 +2070,8 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
const char *format;
const char *msg;
PyObject *keyword;
int i, pos, len;
Py_ssize_t i;
int pos, len;
Py_ssize_t nkwargs;
freelistentry_t static_entries[STATIC_FREELIST_ENTRIES];
freelist_t freelist;

View file

@ -146,7 +146,7 @@ _Py_CalculateSuggestions(PyObject *dir,
if (buffer == NULL) {
return PyErr_NoMemory();
}
for (int i = 0; i < dir_size; ++i) {
for (Py_ssize_t i = 0; i < dir_size; ++i) {
PyObject *item = PyList_GET_ITEM(dir, i);
if (_PyUnicode_Equal(name, item)) {
continue;

View file

@ -398,7 +398,7 @@ _PySymtable_Build(mod_ty mod, PyObject *filename, _PyFutureFeatures *future)
{
struct symtable *st = symtable_new();
asdl_stmt_seq *seq;
int i;
Py_ssize_t i;
PyThreadState *tstate;
int starting_recursion_depth;
@ -1594,7 +1594,7 @@ symtable_enter_type_param_block(struct symtable *st, identifier name,
#define VISIT_SEQ(ST, TYPE, SEQ) \
do { \
int i; \
Py_ssize_t i; \
asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \
for (i = 0; i < asdl_seq_LEN(seq); i++) { \
TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, i); \
@ -1605,7 +1605,7 @@ symtable_enter_type_param_block(struct symtable *st, identifier name,
#define VISIT_SEQ_TAIL(ST, TYPE, SEQ, START) \
do { \
int i; \
Py_ssize_t i; \
asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \
for (i = (START); i < asdl_seq_LEN(seq); i++) { \
TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, i); \
@ -1916,7 +1916,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
VISIT_SEQ(st, alias, s->v.ImportFrom.names);
break;
case Global_kind: {
int i;
Py_ssize_t i;
asdl_identifier_seq *seq = s->v.Global.names;
for (i = 0; i < asdl_seq_LEN(seq); i++) {
identifier name = (identifier)asdl_seq_GET(seq, i);
@ -1952,7 +1952,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
break;
}
case Nonlocal_kind: {
int i;
Py_ssize_t i;
asdl_identifier_seq *seq = s->v.Nonlocal.names;
for (i = 0; i < asdl_seq_LEN(seq); i++) {
identifier name = (identifier)asdl_seq_GET(seq, i);
@ -2494,7 +2494,7 @@ symtable_implicit_arg(struct symtable *st, int pos)
static int
symtable_visit_params(struct symtable *st, asdl_arg_seq *args)
{
int i;
Py_ssize_t i;
if (!args)
return -1;
@ -2555,7 +2555,7 @@ symtable_visit_annotation(struct symtable *st, expr_ty annotation, void *key)
static int
symtable_visit_argannotations(struct symtable *st, asdl_arg_seq *args)
{
int i;
Py_ssize_t i;
if (!args)
return -1;