mirror of
https://github.com/python/cpython.git
synced 2025-09-03 23:41:18 +00:00
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
This commit is contained in:
parent
9fdb76c34c
commit
d73cf7ca85
1 changed files with 3 additions and 3 deletions
|
@ -202,8 +202,8 @@ flatten_args(PyObject* args)
|
||||||
PyTypeObject* arg_type = Py_TYPE(arg);
|
PyTypeObject* arg_type = Py_TYPE(arg);
|
||||||
if (arg_type == &_Py_UnionType) {
|
if (arg_type == &_Py_UnionType) {
|
||||||
PyObject* nested_args = ((unionobject*)arg)->args;
|
PyObject* nested_args = ((unionobject*)arg)->args;
|
||||||
int nested_arg_length = PyTuple_GET_SIZE(nested_args);
|
Py_ssize_t nested_arg_length = PyTuple_GET_SIZE(nested_args);
|
||||||
for (int j = 0; j < nested_arg_length; j++) {
|
for (Py_ssize_t j = 0; j < nested_arg_length; j++) {
|
||||||
PyObject* nested_arg = PyTuple_GET_ITEM(nested_args, j);
|
PyObject* nested_arg = PyTuple_GET_ITEM(nested_args, j);
|
||||||
Py_INCREF(nested_arg);
|
Py_INCREF(nested_arg);
|
||||||
PyTuple_SET_ITEM(flattened_args, pos, nested_arg);
|
PyTuple_SET_ITEM(flattened_args, pos, nested_arg);
|
||||||
|
@ -231,7 +231,7 @@ dedup_and_flatten_args(PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// Add unique elements to an array.
|
// Add unique elements to an array.
|
||||||
int added_items = 0;
|
Py_ssize_t added_items = 0;
|
||||||
for (Py_ssize_t i = 0; i < arg_length; i++) {
|
for (Py_ssize_t i = 0; i < arg_length; i++) {
|
||||||
int is_duplicate = 0;
|
int is_duplicate = 0;
|
||||||
PyObject* i_element = PyTuple_GET_ITEM(args, i);
|
PyObject* i_element = PyTuple_GET_ITEM(args, i);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue