[Python-checkins] bpo-41428: Fix compiler warnings in unionobject.c (GH-22388)
Victor Stinner
webhook-mailer at python.org
Wed Sep 23 17:25:58 EDT 2020
https://github.com/python/cpython/commit/d67de0a30d76c6a28056bae22fd7d13f2e111b77
commit: d67de0a30d76c6a28056bae22fd7d13f2e111b77
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-09-23T23:25:54+02:00
summary:
bpo-41428: Fix compiler warnings in unionobject.c (GH-22388)
Use Py_ssize_t type rather than int, to store lengths in
unionobject.c. Fix warnings:
Objects\unionobject.c(189,71): warning C4244: '+=':
conversion from 'Py_ssize_t' to 'int', possible loss of data
Objects\unionobject.c(182,1): warning C4244: 'initializing':
conversion from 'Py_ssize_t' to 'int', possible loss of data
Objects\unionobject.c(205,1): warning C4244: 'initializing':
conversion from 'Py_ssize_t' to 'int', possible loss of data
Objects\unionobject.c(437,1): warning C4244: 'initializing':
conversion from 'Py_ssize_t' to 'int', possible loss of data
files:
M Objects/unionobject.c
diff --git a/Objects/unionobject.c b/Objects/unionobject.c
index 0ef7abb4c55c2..e055a55e91715 100644
--- a/Objects/unionobject.c
+++ b/Objects/unionobject.c
@@ -179,8 +179,8 @@ union_richcompare(PyObject *a, PyObject *b, int op)
static PyObject*
flatten_args(PyObject* args)
{
- int arg_length = PyTuple_GET_SIZE(args);
- int total_args = 0;
+ Py_ssize_t arg_length = PyTuple_GET_SIZE(args);
+ Py_ssize_t total_args = 0;
// Get number of total args once it's flattened.
for (Py_ssize_t i = 0; i < arg_length; i++) {
PyObject *arg = PyTuple_GET_ITEM(args, i);
@@ -434,7 +434,7 @@ _Py_Union(PyObject *args)
unionobject* result = NULL;
// Check arguments are unionable.
- int nargs = PyTuple_GET_SIZE(args);
+ Py_ssize_t nargs = PyTuple_GET_SIZE(args);
for (Py_ssize_t iarg = 0; iarg < nargs; iarg++) {
PyObject *arg = PyTuple_GET_ITEM(args, iarg);
if (arg == NULL) {
More information about the Python-checkins
mailing list