Skip to content

Commit d73cf7c

Browse files
authored
bpo-41428: Fix compiler warning in unionobject.c (GH-22416)
Use Py_ssize_t type rather than int, to store lengths in unionobject.c. Fix the warning: Objects\unionobject.c(205,1): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
1 parent 9fdb76c commit d73cf7c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Objects/unionobject.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ flatten_args(PyObject* args)
202202
PyTypeObject* arg_type = Py_TYPE(arg);
203203
if (arg_type == &_Py_UnionType) {
204204
PyObject* nested_args = ((unionobject*)arg)->args;
205-
int nested_arg_length = PyTuple_GET_SIZE(nested_args);
206-
for (int j = 0; j < nested_arg_length; j++) {
205+
Py_ssize_t nested_arg_length = PyTuple_GET_SIZE(nested_args);
206+
for (Py_ssize_t j = 0; j < nested_arg_length; j++) {
207207
PyObject* nested_arg = PyTuple_GET_ITEM(nested_args, j);
208208
Py_INCREF(nested_arg);
209209
PyTuple_SET_ITEM(flattened_args, pos, nested_arg);
@@ -231,7 +231,7 @@ dedup_and_flatten_args(PyObject* args)
231231
return NULL;
232232
}
233233
// Add unique elements to an array.
234-
int added_items = 0;
234+
Py_ssize_t added_items = 0;
235235
for (Py_ssize_t i = 0; i < arg_length; i++) {
236236
int is_duplicate = 0;
237237
PyObject* i_element = PyTuple_GET_ITEM(args, i);

0 commit comments

Comments
 (0)