[New-bugs-announce] [issue39611] PyVectorcall_NARGS(): change return type to Py_ssize_t

STINNER Victor report at bugs.python.org
Tue Feb 11 11:50:02 EST 2020

New submission from STINNER Victor <vstinner at python.org>:

I propose to change PyVectorcall_NARGS() return type from unsigned size_t to signed Py_ssize_t.

Currently, the function is defined as:

static inline Py_ssize_t
PyVectorcall_NARGS(size_t n)

But in CPython code base, the result is always stored in a *signed* Py_ssize_t:

    Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);

Sometimes, this nargs is passed to _PyObject_MakeTpCall() which expects nargs to be Py_ssize_t, so it's consistent.

In general in CPython, a size uses type Py_ssize_t, not size_t. Example: PyVarObject.ob_size type is Py_ssize_t.

components: C API
messages: 361824
nosy: jdemeyer, petr.viktorin, vstinner
priority: normal
severity: normal
status: open
title: PyVectorcall_NARGS(): change return type to Py_ssize_t
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list