Skip to content

Commit df56190

Browse files
jdemeyerlisroach
authored andcommitted
bpo-37493: use _PyObject_CallNoArg in more places (pythonGH-14575)
1 parent fc03141 commit df56190

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ done. This can be done using the :c:func:`PyErr_Fetch` and
104104
/* This saves the current exception state */
105105
PyErr_Fetch(&err_type, &err_value, &err_traceback);
106106

107-
cbresult = PyObject_CallObject(self->my_callback, NULL);
107+
cbresult = PyObject_CallNoArgs(self->my_callback);
108108
if (cbresult == NULL)
109109
PyErr_WriteUnraisable(self->my_callback);
110110
else

Modules/_collectionsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ defdict_missing(defdictobject *dd, PyObject *key)
19761976
Py_DECREF(tup);
19771977
return NULL;
19781978
}
1979-
value = PyEval_CallObject(factory, NULL);
1979+
value = _PyObject_CallNoArg(factory);
19801980
if (value == NULL)
19811981
return value;
19821982
if (PyObject_SetItem((PyObject *)dd, key, value) < 0) {

Modules/_ctypes/_ctypes.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,8 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
10011001
stgdict items size, align, length contain info about pointers itself,
10021002
stgdict->proto has info about the pointed to type!
10031003
*/
1004-
stgdict = (StgDictObject *)PyObject_CallObject(
1005-
(PyObject *)&PyCStgDict_Type, NULL);
1004+
stgdict = (StgDictObject *)_PyObject_CallNoArg(
1005+
(PyObject *)&PyCStgDict_Type);
10061006
if (!stgdict)
10071007
return NULL;
10081008
stgdict->size = sizeof(void *);
@@ -1489,8 +1489,8 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
14891489
goto error;
14901490
}
14911491

1492-
stgdict = (StgDictObject *)PyObject_CallObject(
1493-
(PyObject *)&PyCStgDict_Type, NULL);
1492+
stgdict = (StgDictObject *)_PyObject_CallNoArg(
1493+
(PyObject *)&PyCStgDict_Type);
14941494
if (!stgdict)
14951495
goto error;
14961496

@@ -1946,8 +1946,8 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
19461946
if (result == NULL)
19471947
return NULL;
19481948

1949-
stgdict = (StgDictObject *)PyObject_CallObject(
1950-
(PyObject *)&PyCStgDict_Type, NULL);
1949+
stgdict = (StgDictObject *)_PyObject_CallNoArg(
1950+
(PyObject *)&PyCStgDict_Type);
19511951
if (!stgdict) {
19521952
Py_DECREF(result);
19531953
return NULL;
@@ -2060,8 +2060,8 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
20602060
goto error;
20612061
}
20622062

2063-
stgdict = (StgDictObject *)PyObject_CallObject(
2064-
(PyObject *)&PyCStgDict_Type, NULL);
2063+
stgdict = (StgDictObject *)_PyObject_CallNoArg(
2064+
(PyObject *)&PyCStgDict_Type);
20652065
if (!stgdict)
20662066
goto error;
20672067

@@ -2454,8 +2454,8 @@ PyCFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
24542454
PyTypeObject *result;
24552455
StgDictObject *stgdict;
24562456

2457-
stgdict = (StgDictObject *)PyObject_CallObject(
2458-
(PyObject *)&PyCStgDict_Type, NULL);
2457+
stgdict = (StgDictObject *)_PyObject_CallNoArg(
2458+
(PyObject *)&PyCStgDict_Type);
24592459
if (!stgdict)
24602460
return NULL;
24612461

Modules/_ctypes/cfield.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
6060
#define CONT_BITFIELD 2
6161
#define EXPAND_BITFIELD 3
6262

63-
self = (CFieldObject *)PyObject_CallObject((PyObject *)&PyCField_Type,
64-
NULL);
63+
self = (CFieldObject *)_PyObject_CallNoArg((PyObject *)&PyCField_Type);
6564
if (self == NULL)
6665
return NULL;
6766
dict = PyType_stgdict(desc);

Modules/_testcapimodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4907,7 +4907,7 @@ bad_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
49074907
return NULL;
49084908
}
49094909

4910-
PyObject *res = PyObject_CallObject(cls, NULL);
4910+
PyObject *res = _PyObject_CallNoArg(cls);
49114911
if (res == NULL) {
49124912
return NULL;
49134913
}

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ run_at_forkers(PyObject *lst, int reverse)
433433
for (i = 0; i < PyList_GET_SIZE(cpy); i++) {
434434
PyObject *func, *res;
435435
func = PyList_GET_ITEM(cpy, i);
436-
res = PyObject_CallObject(func, NULL);
436+
res = _PyObject_CallNoArg(func);
437437
if (res == NULL)
438438
PyErr_WriteUnraisable(func);
439439
else

0 commit comments

Comments
 (0)