Skip to content

Commit d943d19

Browse files
authored
bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)
* Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
1 parent be21706 commit d943d19

38 files changed

+89
-64
lines changed

Include/cpython/abstract.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,6 @@ _PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs)
160160
return _PyObject_FastCallTstate(tstate, func, args, nargs);
161161
}
162162

163-
/* Call a callable without any arguments
164-
Private static inline function variant of public function
165-
PyObject_CallNoArgs(). */
166-
static inline PyObject *
167-
_PyObject_CallNoArgs(PyObject *func) {
168-
PyThreadState *tstate = PyThreadState_Get();
169-
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
170-
}
171-
172163
static inline PyObject *
173164
PyObject_CallOneArg(PyObject *func, PyObject *arg)
174165
{

Include/internal/pycore_call.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ _PyObject_CallNoArgsTstate(PyThreadState *tstate, PyObject *func) {
3333
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
3434
}
3535

36+
// Private static inline function variant of public PyObject_CallNoArgs()
37+
static inline PyObject *
38+
_PyObject_CallNoArgs(PyObject *func) {
39+
PyThreadState *tstate = PyThreadState_Get();
40+
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
41+
}
42+
3643
#ifdef __cplusplus
3744
}
3845
#endif

Modules/_collectionsmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_call.h" // _PyObject_CallNoArgs()
23
#include "pycore_long.h" // _PyLong_GetZero()
34
#include "structmember.h" // PyMemberDef
45

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ bytes(cdata)
102102
#define PY_SSIZE_T_CLEAN
103103

104104
#include "Python.h"
105+
#include "pycore_call.h" // _PyObject_CallNoArgs()
105106
#include "structmember.h" // PyMemberDef
106107

107108
#include <ffi.h>

Modules/_ctypes/callbacks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_call.h" // _PyObject_CallNoArgs()
23
#include "frameobject.h"
34

45
#include <stdbool.h>

Modules/_ctypes/cfield.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Python.h"
22
#include "pycore_bitutils.h" // _Py_bswap32()
3+
#include "pycore_call.h" // _PyObject_CallNoArgs()
34

45
#include <ffi.h>
56
#ifdef MS_WIN32

Modules/_ctypes/stgdict.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_call.h" // _PyObject_CallNoArgs()
23
#include <ffi.h>
34
#ifdef MS_WIN32
45
#include <windows.h>

Modules/_functoolsmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_call.h" // _PyObject_CallNoArgs()
23
#include "pycore_long.h" // _PyLong_GetZero()
34
#include "pycore_moduleobject.h" // _PyModule_GetState()
45
#include "pycore_object.h" // _PyObject_GC_TRACK

Modules/_io/bufferedio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#define PY_SSIZE_T_CLEAN
1111
#include "Python.h"
12+
#include "pycore_call.h" // _PyObject_CallNoArgs()
1213
#include "pycore_object.h"
1314
#include "structmember.h" // PyMemberDef
1415
#include "_iomodule.h"

Modules/_lsprof.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_call.h" // _PyObject_CallNoArgs()
23
#include "rotatingtree.h"
34

45
/************************************************************/

0 commit comments

Comments
 (0)