pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/e7315543377322e4c6e0d8d2c4a4bb4626e43f4c

97560d244c08.css" /> Fixes loop variables to be the same types as their limit (GH-120958) · python/cpython@e731554 · GitHub
Skip to content

Commit e731554

Browse files
authored
Fixes loop variables to be the same types as their limit (GH-120958)
1 parent 2e15785 commit e731554

File tree

14 files changed

+26
-26
lines changed

14 files changed

+26
-26
lines changed

Modules/_io/_iomodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
202202
const char *newline, int closefd, PyObject *opener)
203203
/*[clinic end generated code: output=aefafc4ce2b46dc0 input=cd034e7cdfbf4e78]*/
204204
{
205-
unsigned i;
205+
size_t i;
206206

207207
int creating = 0, reading = 0, writing = 0, appending = 0, updating = 0;
208208
int text = 0, binary = 0;

Modules/_sqlite/blob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ blob_close_impl(pysqlite_Blob *self)
9999
void
100100
pysqlite_close_all_blobs(pysqlite_Connection *self)
101101
{
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++) {
103103
PyObject *weakref = PyList_GET_ITEM(self->blobs, i);
104104
PyObject *blob;
105105
if (!PyWeakref_GetRef(weakref, &blob)) {

Modules/_testinternalcapi/test_critical_sections.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ test_critical_sections_threads(PyObject *self, PyObject *Py_UNUSED(args))
185185
assert(test_data.obj2 != NULL);
186186
assert(test_data.obj3 != NULL);
187187

188-
for (int i = 0; i < NUM_THREADS; i++) {
188+
for (Py_ssize_t i = 0; i < NUM_THREADS; i++) {
189189
PyThread_start_new_thread(&thread_critical_sections, &test_data);
190190
}
191191
PyEvent_Wait(&test_data.done_event);
@@ -271,7 +271,7 @@ test_critical_sections_gc(PyObject *self, PyObject *Py_UNUSED(args))
271271
};
272272
assert(test_data.obj != NULL);
273273

274-
for (int i = 0; i < NUM_THREADS; i++) {
274+
for (Py_ssize_t i = 0; i < NUM_THREADS; i++) {
275275
PyThread_start_new_thread(&thread_gc, &test_data);
276276
}
277277
PyEvent_Wait(&test_data.done_event);

Objects/codeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ get_line_delta(const uint8_t *ptr)
573573
static PyObject *
574574
remove_column_info(PyObject *locations)
575575
{
576-
int offset = 0;
576+
Py_ssize_t offset = 0;
577577
const uint8_t *data = (const uint8_t *)PyBytes_AS_STRING(locations);
578578
PyObject *res = PyBytes_FromStringAndSize(NULL, 32);
579579
if (res == NULL) {

Objects/unicodeobject.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8373,7 +8373,7 @@ PyUnicode_BuildEncodingMap(PyObject* string)
83738373
int count2 = 0, count3 = 0;
83748374
int kind;
83758375
const void *data;
8376-
Py_ssize_t length;
8376+
int length;
83778377
Py_UCS4 ch;
83788378

83798379
if (!PyUnicode_Check(string) || !PyUnicode_GET_LENGTH(string)) {
@@ -8382,8 +8382,7 @@ PyUnicode_BuildEncodingMap(PyObject* string)
83828382
}
83838383
kind = PyUnicode_KIND(string);
83848384
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);
83878386
memset(level1, 0xFF, sizeof level1);
83888387
memset(level2, 0xFF, sizeof level2);
83898388

Objects/unionobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ is_same(PyObject *left, PyObject *right)
8181
static int
8282
contains(PyObject **items, Py_ssize_t size, PyObject *obj)
8383
{
84-
for (int i = 0; i < size; i++) {
84+
for (Py_ssize_t i = 0; i < size; i++) {
8585
int is_duplicate = is_same(items[i], obj);
8686
if (is_duplicate) { // -1 or 1
8787
return is_duplicate;
@@ -97,7 +97,7 @@ merge(PyObject **items1, Py_ssize_t size1,
9797
PyObject *tuple = NULL;
9898
Py_ssize_t pos = 0;
9999

100-
for (int i = 0; i < size2; i++) {
100+
for (Py_ssize_t i = 0; i < size2; i++) {
101101
PyObject *arg = items2[i];
102102
int is_duplicate = contains(items1, size1, arg);
103103
if (is_duplicate < 0) {

Parser/action_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ _PyPegen_make_module(Parser *p, asdl_stmt_seq *a) {
864864
if (type_ignores == NULL) {
865865
return NULL;
866866
}
867-
for (int i = 0; i < num; i++) {
867+
for (Py_ssize_t i = 0; i < num; i++) {
868868
PyObject *tag = _PyPegen_new_type_comment(p, p->type_ignore_comments.items[i].comment);
869869
if (tag == NULL) {
870870
return NULL;

Python/ast_opt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
521521
static PyObject*
522522
make_const_tuple(asdl_expr_seq *elts)
523523
{
524-
for (int i = 0; i < asdl_seq_LEN(elts); i++) {
524+
for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) {
525525
expr_ty e = (expr_ty)asdl_seq_GET(elts, i);
526526
if (e->kind != Constant_kind) {
527527
return NULL;
@@ -533,7 +533,7 @@ make_const_tuple(asdl_expr_seq *elts)
533533
return NULL;
534534
}
535535

536-
for (int i = 0; i < asdl_seq_LEN(elts); i++) {
536+
for (Py_ssize_t i = 0; i < asdl_seq_LEN(elts); i++) {
537537
expr_ty e = (expr_ty)asdl_seq_GET(elts, i);
538538
PyObject *v = e->v.Constant.value;
539539
PyTuple_SET_ITEM(newval, i, Py_NewRef(v));
@@ -650,7 +650,7 @@ static int astfold_type_param(type_param_ty node_, PyArena *ctx_, _PyASTOptimize
650650
return 0;
651651

652652
#define CALL_SEQ(FUNC, TYPE, ARG) { \
653-
int i; \
653+
Py_ssize_t i; \
654654
asdl_ ## TYPE ## _seq *seq = (ARG); /* avoid variable capture */ \
655655
for (i = 0; i < asdl_seq_LEN(seq); i++) { \
656656
TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, i); \

Python/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5109,7 +5109,7 @@ compiler_call_simple_kw_helper(struct compiler *c, location loc,
51095109
if (names == NULL) {
51105110
return ERROR;
51115111
}
5112-
for (int i = 0; i < nkwelts; i++) {
5112+
for (Py_ssize_t i = 0; i < nkwelts; i++) {
51135113
keyword_ty kw = asdl_seq_GET(keywords, i);
51145114
PyTuple_SET_ITEM(names, i, Py_NewRef(kw->arg));
51155115
}

Python/flowgraph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ remove_unused_consts(basicblock *entryblock, PyObject *consts)
20952095
/* now index_map[i] == i if consts[i] is used, -1 otherwise */
20962096
/* condense consts */
20972097
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++) {
20992099
if (index_map[i] != -1) {
21002100
assert(index_map[i] == i);
21012101
index_map[n_used_consts++] = index_map[i];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy