diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-05-20 14:57:26 -0500 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-05-20 15:14:10 -0500 |
| commit | a77c3f646e25ff806daeb40d2ee5b9ad0ed74588 (patch) | |
| tree | 115c0ab62a3df8bca6cc8b78bda67d700d60690c /numpy | |
| parent | 84809accddc771d525319c227d78c0152b1f7874 (diff) | |
| download | numpy-a77c3f646e25ff806daeb40d2ee5b9ad0ed74588.tar.gz | |
MAINT: Stop Using PyEval_Call* and simplify some uses
Python 3.9 started to deprecate these calls and the PyObject_Call*
variants are equivalent or nicer in any case.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/strfuncs.c | 12 | ||||
| -rw-r--r-- | numpy/core/src/umath/loops.c.src | 11 |
2 files changed, 6 insertions, 17 deletions
diff --git a/numpy/core/src/multiarray/strfuncs.c b/numpy/core/src/multiarray/strfuncs.c index b570aec08..363cbdba2 100644 --- a/numpy/core/src/multiarray/strfuncs.c +++ b/numpy/core/src/multiarray/strfuncs.c @@ -168,15 +168,13 @@ array_repr_builtin(PyArrayObject *self, int repr) NPY_NO_EXPORT PyObject * array_repr(PyArrayObject *self) { - PyObject *s, *arglist; + PyObject *s; if (PyArray_ReprFunction == NULL) { s = array_repr_builtin(self, 1); } else { - arglist = Py_BuildValue("(O)", self); - s = PyEval_CallObject(PyArray_ReprFunction, arglist); - Py_DECREF(arglist); + s = PyObject_CallFunctionObjArgs(PyArray_ReprFunction, self, NULL); } return s; } @@ -185,15 +183,13 @@ array_repr(PyArrayObject *self) NPY_NO_EXPORT PyObject * array_str(PyArrayObject *self) { - PyObject *s, *arglist; + PyObject *s; if (PyArray_StrFunction == NULL) { s = array_repr_builtin(self, 0); } else { - arglist = Py_BuildValue("(O)", self); - s = PyEval_CallObject(PyArray_StrFunction, arglist); - Py_DECREF(arglist); + s = PyObject_CallFunctionObjArgs(PyArray_StrFunction, self, NULL); } return s; } diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index a5c663a47..a59a9acf5 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -225,10 +225,6 @@ NPY_NO_EXPORT void PyUFunc_O_O_method(char **args, npy_intp const *dimensions, npy_intp const *steps, void *func) { char *meth = (char *)func; - PyObject *tup = PyTuple_New(0); - if (tup == NULL) { - return; - } UNARY_LOOP { PyObject *in1 = *(PyObject **)ip1; PyObject **out = (PyObject **)op1; @@ -247,20 +243,17 @@ PyUFunc_O_O_method(char **args, npy_intp const *dimensions, npy_intp const *step "type %s which has no callable %s method", i, type->tp_name, meth); npy_PyErr_ChainExceptionsCause(exc, val, tb); - Py_DECREF(tup); Py_XDECREF(func); return; } - ret = PyObject_Call(func, tup, NULL); + ret = PyObject_CallObject(func, NULL); Py_DECREF(func); if (ret == NULL) { - Py_DECREF(tup); return; } Py_XDECREF(*out); *out = ret; } - Py_DECREF(tup); } /*UFUNC_API*/ @@ -359,7 +352,7 @@ PyUFunc_On_Om(char **args, npy_intp const *dimensions, npy_intp const *steps, vo PyTuple_SET_ITEM(arglist, j, in); Py_INCREF(in); } - result = PyEval_CallObject(tocall, arglist); + result = PyObject_CallObject(tocall, arglist); Py_DECREF(arglist); if (result == NULL) { return; |
