GeezerVison is showing github.com — Fixes loop variables to be the same types as their limit (GH-120958) · Maddie-Code-Collab/cpython@e731554
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Modules/_io/_iomodule.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -202,7 +202,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode, | 202 | 202 | const char *newline, int closefd, PyObject *opener) | 203 | 203 | /*[clinic end generated code: output=aefafc4ce2b46dc0 input=cd034e7cdfbf4e78]*/ | 204 | 204 | { | 205 | | - unsigned i; | | 205 | + size_t i; | 206 | 206 |
| 207 | 207 | int creating = 0, reading = 0, writing = 0, appending = 0, updating = 0; | 208 | 208 | int text = 0, binary = 0; | |
Collapse file Copy file name to clipboardExpand all lines: Modules/_sqlite/blob.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -99,7 +99,7 @@ blob_close_impl(pysqlite_Blob *self) | 99 | 99 | void | 100 | 100 | pysqlite_close_all_blobs(pysqlite_Connection *self) | 101 | 101 | { | 102 | | - for (int i = 0; i < PyList_GET_SIZE(self->blobs); i++) { | | 102 | + for (Py_ssize_t i = 0; i < PyList_GET_SIZE(self->blobs); i++) { | 103 | 103 | PyObject *weakref = PyList_GET_ITEM(self->blobs, i); | 104 | 104 | PyObject *blob; | 105 | 105 | if (!PyWeakref_GetRef(weakref, &blob)) { | |
Collapse file Copy file name to clipboardExpand all lines: Modules/_testinternalcapi/test_critical_sections.c +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -185,7 +185,7 @@ test_critical_sections_threads(PyObject *self, PyObject *Py_UNUSED(args)) | 185 | 185 | assert(test_data.obj2 != NULL); | 186 | 186 | assert(test_data.obj3 != NULL); | 187 | 187 |
| 188 | | - for (int i = 0; i < NUM_THREADS; i++) { | | 188 | + for (Py_ssize_t i = 0; i < NUM_THREADS; i++) { | 189 | 189 | PyThread_start_new_thread(&thread_critical_sections, &test_data); | 190 | 190 | } | 191 | 191 | PyEvent_Wait(&test_data.done_event); | @@ -271,7 +271,7 @@ test_critical_sections_gc(PyObject *self, PyObject *Py_UNUSED(args)) | 271 | 271 | }; | 272 | 272 | assert(test_data.obj != NULL); | 273 | 273 |
| 274 | | - for (int i = 0; i < NUM_THREADS; i++) { | | 274 | + for (Py_ssize_t i = 0; i < NUM_THREADS; i++) { | 275 | 275 | PyThread_start_new_thread(&thread_gc, &test_data); | 276 | 276 | } | 277 | 277 | PyEvent_Wait(&test_data.done_event); | |
Collapse file Copy file name to clipboardExpand all lines: Objects/codeobject.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -573,7 +573,7 @@ get_line_delta(const uint8_t *ptr) | 573 | 573 | static PyObject * | 574 | 574 | remove_column_info(PyObject *locations) | 575 | 575 | { | 576 | | - int offset = 0; | | 576 | + Py_ssize_t offset = 0; | 577 | 577 | const uint8_t *data = (const uint8_t *)PyBytes_AS_STRING(locations); | 578 | 578 | PyObject *res = PyBytes_FromStringAndSize(NULL, 32); | 579 | 579 | if (res == NULL) { | |
Collapse file Copy file name to clipboardExpand all lines: Objects/unicodeobject.c +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8373,7 +8373,7 @@ PyUnicode_BuildEncodingMap(PyObject* string) | 8373 | 8373 | int count2 = 0, count3 = 0; | 8374 | 8374 | int kind; | 8375 | 8375 | const void *data; | 8376 | | - Py_ssize_t length; | | 8376 | + int length; | 8377 | 8377 | Py_UCS4 ch; | 8378 | 8378 |
| 8379 | 8379 | if (!PyUnicode_Check(string) || !PyUnicode_GET_LENGTH(string)) { | @@ -8382,8 +8382,7 @@ PyUnicode_BuildEncodingMap(PyObject* string) | 8382 | 8382 | } | 8383 | 8383 | kind = PyUnicode_KIND(string); | 8384 | 8384 | data = PyUnicode_DATA(string); | 8385 | | - length = PyUnicode_GET_LENGTH(string); | 8386 | | - length = Py_MIN(length, 256); | | 8385 | + length = (int)Py_MIN(PyUnicode_GET_LENGTH(string), 256); | 8387 | 8386 | memset(level1, 0xFF, sizeof level1); | 8388 | 8387 | memset(level2, 0xFF, sizeof level2); | 8389 | 8388 |
| |
Collapse file Copy file name to clipboardExpand all lines: Objects/unionobject.c +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -81,7 +81,7 @@ is_same(PyObject *left, PyObject *right) | 81 | 81 | static int | 82 | 82 | contains(PyObject **items, Py_ssize_t size, PyObject *obj) | 83 | 83 | { | 84 | | - for (int i = 0; i < size; i++) { | | 84 | + for (Py_ssize_t i = 0; i < size; i++) { | 85 | 85 | int is_duplicate = is_same(items[i], obj); | 86 | 86 | if (is_duplicate) { // -1 or 1 | 87 | 87 | return is_duplicate; | @@ -97,7 +97,7 @@ merge(PyObject **items1, Py_ssize_t size1, | 97 | 97 | PyObject *tuple = NULL; | 98 | 98 | Py_ssize_t pos = 0; | 99 | 99 |
| 100 | | - for (int i = 0; i < size2; i++) { | | 100 | + for (Py_ssize_t i = 0; i < size2; i++) { | 101 | 101 | PyObject *arg = items2[i]; | 102 | 102 | int is_duplicate = contains(items1, size1, arg); | 103 | 103 | if (is_duplicate < 0) { | |
Collapse file Copy file name to clipboardExpand all lines: Parser/action_helpers.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -864,7 +864,7 @@ _PyPegen_make_module(Parser *p, asdl_stmt_seq *a) { | 864 | 864 | if (type_ignores == NULL) { | 865 | 865 | return NULL; | 866 | 866 | } | 867 | | - for (int i = 0; i < num; i++) { | | 867 | + for (Py_ssize_t i = 0; i < num; i++) { | 868 | 868 | PyObject *tag = _PyPegen_new_type_comment(p, p->type_ignore_comments.items[i].comment); | 869 | 869 | if (tag == NULL) { | 870 | 870 | return NULL; | |
Collapse file Copy file name to clipboardExpand all lines: Python/ast_opt.c +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -521,7 +521,7 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state) | 521 | 521 | static PyObject* | 522 | 522 | make_const_tuple(asdl_expr_seq *elts) | 523 | 523 | { | 524 | | - for (int i = 0; i < asdl_seq_LEN(elts); i++) { | | 524 | + for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) { | 525 | 525 | expr_ty e = (expr_ty)asdl_seq_GET(elts, i); | 526 | 526 | if (e->kind != Constant_kind) { | 527 | 527 | return NULL; | @@ -533,7 +533,7 @@ make_const_tuple(asdl_expr_seq *elts) | 533 | 533 | return NULL; | 534 | 534 | } | 535 | 535 |
| 536 | | - for (int i = 0; i < asdl_seq_LEN(elts); i++) { | | 536 | + for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) { | 537 | 537 | expr_ty e = (expr_ty)asdl_seq_GET(elts, i); | 538 | 538 | PyObject *v = e->v.Constant.value; | 539 | 539 | PyTuple_SET_ITEM(newval, i, Py_NewRef(v)); | @@ -650,7 +650,7 @@ static int astfold_type_param(type_param_ty node_, PyArena *ctx_, _PyASTOptimize | 650 | 650 | return 0; | 651 | 651 |
| 652 | 652 | #define CALL_SEQ(FUNC, TYPE, ARG) { \ | 653 | | - int i; \ | | 653 | + Py_ssize_t i; \ | 654 | 654 | asdl_ ## TYPE ## _seq *seq = (ARG); /* avoid variable capture */ \ | 655 | 655 | for (i = 0; i < asdl_seq_LEN(seq); i++) { \ | 656 | 656 | TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, i); \ | |
Collapse file Copy file name to clipboardExpand all lines: Python/compile.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -5109,7 +5109,7 @@ compiler_call_simple_kw_helper(struct compiler *c, location loc, | 5109 | 5109 | if (names == NULL) { | 5110 | 5110 | return ERROR; | 5111 | 5111 | } | 5112 | | - for (int i = 0; i < nkwelts; i++) { | | 5112 | + for (Py_ssize_t i = 0; i < nkwelts; i++) { | 5113 | 5113 | keyword_ty kw = asdl_seq_GET(keywords, i); | 5114 | 5114 | PyTuple_SET_ITEM(names, i, Py_NewRef(kw->arg)); | 5115 | 5115 | } | |
Collapse file Copy file name to clipboardExpand all lines: Python/flowgraph.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2095,7 +2095,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts) | 2095 | 2095 | /* now index_map[i] == i if consts[i] is used, -1 otherwise */ | 2096 | 2096 | /* condense consts */ | 2097 | 2097 | Py_ssize_t n_used_consts = 0; | 2098 | | - for (int i = 0; i < nconsts; i++) { | | 2098 | + for (Py_ssize_t i = 0; i < nconsts; i++) { | 2099 | 2099 | if (index_map[i] != -1) { | 2100 | 2100 | assert(index_map[i] == i); | 2101 | 2101 | index_map[n_used_consts++] = index_map[i]; | |
|