[issue39648] Update math.gcd() to accept "n" arguments.

Ananthakrishnan report at bugs.python.org
Fri Feb 21 01:41:40 EST 2020


Ananthakrishnan <ananthakrishnan15.2001 at gmail.com> added the comment:

This is my code for math.gcd:

static PyObject *
math_gcd(PyObject *module, PyObject *args, Py_ssize_t n)
{
    PyObject *g = 0, *item, *in;
    
    Py_ssize_t i;
    for (i = 0; i < n; i++) {
        item = args[i];
        in = PyNumber_Index(item);
        if (in == NULL) {
            return NULL;
        }
        g = _PyLong_GCD(g, in);
    }
    Py_DECREF(in);
    return g;
}



This is showing an error:

error: incompatible types when assigning to type ‘PyObject * {aka struct _object *}’ from type ‘PyObject {aka struct _object}’
       item = args[i];
           ^^^

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39648>
_______________________________________


More information about the Python-bugs-list mailing list