From d943d19172aa93ce88bade15b9f23a0ce3bc72ff Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 12 Oct 2021 08:38:19 +0200 Subject: 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(). --- Include/cpython/abstract.h | 9 --------- Include/internal/pycore_call.h | 7 +++++++ Modules/_collectionsmodule.c | 1 + Modules/_ctypes/_ctypes.c | 1 + Modules/_ctypes/callbacks.c | 1 + Modules/_ctypes/cfield.c | 1 + Modules/_ctypes/stgdict.c | 1 + Modules/_functoolsmodule.c | 1 + Modules/_io/bufferedio.c | 1 + Modules/_lsprof.c | 1 + Modules/_sqlite/connection.c | 4 ++-- Modules/_ssl.c | 2 +- Modules/_testcapimodule.c | 12 ++++++------ Modules/itertoolsmodule.c | 3 +-- Modules/main.c | 1 + Modules/mathmodule.c | 3 ++- Modules/posixmodule.c | 3 ++- Modules/signalmodule.c | 2 +- Objects/abstract.c | 1 + Objects/bytesobject.c | 1 + Objects/complexobject.c | 1 + Objects/dictobject.c | 15 ++++++++------- Objects/enumobject.c | 1 + Objects/fileobject.c | 3 ++- Objects/genobject.c | 9 +++++---- Objects/iterobject.c | 3 ++- Objects/moduleobject.c | 1 + Objects/object.c | 13 +++++++------ Objects/odictobject.c | 6 +++--- Objects/typeobject.c | 10 +++++----- Parser/tokenizer.c | 1 + Python/bltinmodule.c | 1 + Python/ceval.c | 4 ++-- Python/codecs.c | 1 + Python/errors.c | 11 ++++++----- Python/marshal.c | 7 ++++--- Python/sysmodule.c | 7 ++++--- setup.py | 3 ++- 38 files changed, 89 insertions(+), 64 deletions(-) diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index 18bf013..0814bfa 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -160,15 +160,6 @@ _PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs) return _PyObject_FastCallTstate(tstate, func, args, nargs); } -/* Call a callable without any arguments - Private static inline function variant of public function - PyObject_CallNoArgs(). */ -static inline PyObject * -_PyObject_CallNoArgs(PyObject *func) { - PyThreadState *tstate = PyThreadState_Get(); - return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL); -} - static inline PyObject * PyObject_CallOneArg(PyObject *func, PyObject *arg) { diff --git a/Include/internal/pycore_call.h b/Include/internal/pycore_call.h index 2f7c07a..28a4194 100644 --- a/Include/internal/pycore_call.h +++ b/Include/internal/pycore_call.h @@ -33,6 +33,13 @@ _PyObject_CallNoArgsTstate(PyThreadState *tstate, PyObject *func) { return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL); } +// Private static inline function variant of public PyObject_CallNoArgs() +static inline PyObject * +_PyObject_CallNoArgs(PyObject *func) { + PyThreadState *tstate = PyThreadState_Get(); + return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL); +} + #ifdef __cplusplus } #endif diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 8a690b4..c6de963 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_long.h" // _PyLong_GetZero() #include "structmember.h" // PyMemberDef diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 7ff101e..2567067 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -102,6 +102,7 @@ bytes(cdata) #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "structmember.h" // PyMemberDef #include diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 16afb24..18b0104 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "frameobject.h" #include diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 2909f2f..6788aee 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1,5 +1,6 @@ #include "Python.h" #include "pycore_bitutils.h" // _Py_bswap32() +#include "pycore_call.h" // _PyObject_CallNoArgs() #include #ifdef MS_WIN32 diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index d44b54c..ea3c58b 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include #ifdef MS_WIN32 #include diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index ed60ae3..4c77ee7 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_long.h" // _PyLong_GetZero() #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_object.h" // _PyObject_GC_TRACK diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 74d4fb5..dc6371a 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -9,6 +9,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_object.h" #include "structmember.h" // PyMemberDef #include "_iomodule.h" diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 0ca3f1e..097d0eff 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "rotatingtree.h" /************************************************************/ diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index a331757..b4badb1 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -710,7 +710,7 @@ step_callback(sqlite3_context *context, int argc, sqlite3_value **params) if (*aggregate_instance == NULL) { callback_context *ctx = (callback_context *)sqlite3_user_data(context); assert(ctx != NULL); - *aggregate_instance = _PyObject_CallNoArgs(ctx->callable); + *aggregate_instance = PyObject_CallNoArgs(ctx->callable); if (!*aggregate_instance) { set_sqlite_error(context, "user-defined aggregate's '__init__' method raised error"); @@ -1008,7 +1008,7 @@ progress_callback(void *ctx) assert(ctx != NULL); PyObject *callable = ((callback_context *)ctx)->callable; - ret = _PyObject_CallNoArgs(callable); + ret = PyObject_CallNoArgs(callable); if (!ret) { /* abort query if error occurred */ rc = -1; diff --git a/Modules/_ssl.c b/Modules/_ssl.c index c163ce6..b2e241a 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3773,7 +3773,7 @@ _password_callback(char *buf, int size, int rwflag, void *userdata) } if (pw_info->callable) { - fn_ret = _PyObject_CallNoArgs(pw_info->callable); + fn_ret = PyObject_CallNoArgs(pw_info->callable); if (!fn_ret) { /* TODO: It would be nice to move _ctypes_add_traceback() into the core python API, so we could use it to add a frame here */ diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 775464c..7cbd2dc 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2866,7 +2866,7 @@ _make_call(void *callable) PyObject *rc; int success; PyGILState_STATE s = PyGILState_Ensure(); - rc = _PyObject_CallNoArgs((PyObject *)callable); + rc = PyObject_CallNoArgs((PyObject *)callable); success = (rc != NULL); Py_XDECREF(rc); PyGILState_Release(s); @@ -2937,7 +2937,7 @@ static int _pending_callback(void *arg) { /* we assume the argument is callable object to which we own a reference */ PyObject *callable = (PyObject *)arg; - PyObject *r = _PyObject_CallNoArgs(callable); + PyObject *r = PyObject_CallNoArgs(callable); Py_DECREF(callable); Py_XDECREF(r); return r != NULL ? 0 : -1; @@ -3729,7 +3729,7 @@ slot_tp_del(PyObject *self) /* Execute __del__ method, if any. */ del = _PyObject_LookupSpecial(self, &PyId___tp_del__); if (del != NULL) { - res = _PyObject_CallNoArgs(del); + res = PyObject_CallNoArgs(del); if (res == NULL) PyErr_WriteUnraisable(del); else @@ -4358,7 +4358,7 @@ temporary_c_thread(void *data) /* Allocate a Python thread state for this thread */ state = PyGILState_Ensure(); - res = _PyObject_CallNoArgs(test_c_thread->callback); + res = PyObject_CallNoArgs(test_c_thread->callback); Py_CLEAR(test_c_thread->callback); if (res == NULL) { @@ -4893,7 +4893,7 @@ check_pyobject_freed_is_freed(PyObject *self, PyObject *Py_UNUSED(args)) #ifdef _Py_ADDRESS_SANITIZER Py_RETURN_NONE; #else - PyObject *op = _PyObject_CallNoArgs((PyObject *)&PyBaseObject_Type); + PyObject *op = PyObject_CallNoArgs((PyObject *)&PyBaseObject_Type); if (op == NULL) { return NULL; } @@ -5271,7 +5271,7 @@ bad_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs) return NULL; } - PyObject *res = _PyObject_CallNoArgs(cls); + PyObject *res = PyObject_CallNoArgs(cls); if (res == NULL) { return NULL; } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index d6f898c..342a3e6 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -1,7 +1,6 @@ - - #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_long.h" // _PyLong_GetZero() #include "pycore_object.h" // _PyObject_GC_TRACK() #include "pycore_tuple.h" // _PyTuple_ITEMS() diff --git a/Modules/main.c b/Modules/main.c index 39b8c71..c537e6b 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -1,6 +1,7 @@ /* Python interpreter main program */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_initconfig.h" // _PyArgv #include "pycore_interp.h" // _PyInterpreterState.sysdict #include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0() diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 62acece..4fac0cc 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -54,7 +54,8 @@ raised for division by zero and mod by zero. #include "Python.h" #include "pycore_bitutils.h" // _Py_bit_length() -#include "pycore_dtoa.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_dtoa.h" // _Py_dg_infinity() #include "pycore_long.h" // _PyLong_GetZero() #include "_math.h" diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 01012c1..ada1a58 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -10,7 +10,8 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_fileutils.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_fileutils.h" // _Py_closerange() #include "pycore_moduleobject.h" // _PyModule_GetState() #ifdef MS_WINDOWS /* include early to avoid conflict with pycore_condvar.h: diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index d5e6a43..6568a4d 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -7,7 +7,7 @@ #include "pycore_atomic.h" // _Py_atomic_int #include "pycore_call.h" // _PyObject_Call() #include "pycore_ceval.h" // _PyEval_SignalReceived() -#include "pycore_frame.h" +#include "pycore_frame.h" // InterpreterFrame #include "pycore_moduleobject.h" // _PyModule_GetState() #include "pycore_pyerrors.h" // _PyErr_SetString() #include "pycore_pylifecycle.h" // NSIG diff --git a/Objects/abstract.c b/Objects/abstract.c index 3312e26..0d6cefd 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -2,6 +2,7 @@ #include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _Py_EnterRecursiveCall() #include "pycore_object.h" // _Py_CheckSlotResult() #include "pycore_pyerrors.h" // _PyErr_Occurred() diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 0dfded2..bc0b075 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -5,6 +5,7 @@ #include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_bytes_methods.h" // _Py_bytes_startswith() +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_format.h" // F_LJUST #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_object.h" // _PyObject_GC_TRACK diff --git a/Objects/complexobject.c b/Objects/complexobject.c index ff8fcba..f658dbf 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -6,6 +6,7 @@ /* Submitted by Jim Hugunin */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_long.h" // _PyLong_GetZero() #include "pycore_object.h" // _PyObject_Init() #include "pycore_pymath.h" // _Py_ADJUST_ERANGE2() diff --git a/Objects/dictobject.c b/Objects/dictobject.c index f883ca7..60470bf 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -112,13 +112,14 @@ As a consequence of this, split keys have a maximum size of 16. #define PyDict_MINSIZE 8 #include "Python.h" -#include "pycore_bitutils.h" // _Py_bit_length -#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED() -#include "pycore_object.h" // _PyObject_GC_TRACK() -#include "pycore_pyerrors.h" // _PyErr_Fetch() -#include "pycore_pystate.h" // _PyThreadState_GET() -#include "pycore_dict.h" -#include "stringlib/eq.h" // unicode_eq() +#include "pycore_bitutils.h" // _Py_bit_length +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_dict.h" // PyDictKeysObject +#include "pycore_gc.h" // _PyObject_GC_IS_TRACKED() +#include "pycore_object.h" // _PyObject_GC_TRACK() +#include "pycore_pyerrors.h" // _PyErr_Fetch() +#include "pycore_pystate.h" // _PyThreadState_GET() +#include "stringlib/eq.h" // unicode_eq() /*[clinic input] class dict "PyDictObject *" "&PyDict_Type" diff --git a/Objects/enumobject.c b/Objects/enumobject.c index aae7dff..4513831 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -1,6 +1,7 @@ /* enumerate object */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_long.h" // _PyLong_GetOne() #include "pycore_object.h" // _PyObject_GC_TRACK() diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 5cb017e8..dc600c6 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -2,7 +2,8 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_runtime.h" // _PyRuntime +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_runtime.h" // _PyRuntime #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER) /* clang MemorySanitizer doesn't yet understand getc_unlocked. */ diff --git a/Objects/genobject.c b/Objects/genobject.c index 8fa04e8..f91f367 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -1,14 +1,15 @@ /* Generator object implementation */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _PyEval_EvalFrame() -#include "pycore_object.h" +#include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_pyerrors.h" // _PyErr_ClearExcState() #include "pycore_pystate.h" // _PyThreadState_GET() -#include "frameobject.h" -#include "pycore_frame.h" +#include "pycore_frame.h" // InterpreterFrame +#include "frameobject.h" // PyFrameObject #include "structmember.h" // PyMemberDef -#include "opcode.h" +#include "opcode.h" // YIELD_FROM static PyObject *gen_close(PyGenObject *, PyObject *); static PyObject *async_gen_asend_new(PyAsyncGenObject *, PyObject *); diff --git a/Objects/iterobject.c b/Objects/iterobject.c index acfc539..5db6bc1 100644 --- a/Objects/iterobject.c +++ b/Objects/iterobject.c @@ -1,7 +1,8 @@ /* Iterator objects */ #include "Python.h" -#include "pycore_object.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_object.h" // _PyObject_GC_TRACK() typedef struct { PyObject_HEAD diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index f008995..1d649a7 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -2,6 +2,7 @@ /* Module object implementation */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_interp.h" // PyInterpreterState.importlib #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_moduleobject.h" // _PyModule_GetDef() diff --git a/Objects/object.c b/Objects/object.c index d269274..9d48346 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2,18 +2,19 @@ /* Generic object operations; and implementation of None */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _Py_EnterRecursiveCall() #include "pycore_context.h" -#include "pycore_initconfig.h" -#include "pycore_object.h" -#include "pycore_pyerrors.h" -#include "pycore_pylifecycle.h" +#include "pycore_initconfig.h" // _PyStatus_EXCEPTION() +#include "pycore_object.h" // _PyType_CheckConsistency() +#include "pycore_pyerrors.h" // _PyErr_Occurred() +#include "pycore_pylifecycle.h" // _PyTypes_InitSlotDefs() #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_symtable.h" // PySTEntry_Type #include "pycore_unionobject.h" // _PyUnion_Type -#include "frameobject.h" -#include "interpreteridobject.h" +#include "frameobject.h" // PyFrame_Type +#include "interpreteridobject.h" // _PyInterpreterID_Type #ifdef Py_LIMITED_API // Prevent recursive call _Py_IncRef() <=> Py_INCREF() diff --git a/Objects/odictobject.c b/Objects/odictobject.c index 1462a3b..9af45c6 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -465,10 +465,10 @@ later: */ #include "Python.h" -#include "pycore_object.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_object.h" // _PyObject_GC_UNTRACK() +#include "pycore_dict.h" // _Py_dict_lookup() #include // offsetof() -#include "pycore_dict.h" -#include #include "clinic/odictobject.c.h" diff --git a/Objects/typeobject.c b/Objects/typeobject.c index a73a696..0f56e59 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4,14 +4,14 @@ #include "pycore_call.h" #include "pycore_code.h" // CO_FAST_FREE #include "pycore_compile.h" // _Py_Mangle() -#include "pycore_initconfig.h" +#include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_moduleobject.h" // _PyModule_GetDef() -#include "pycore_object.h" -#include "pycore_pyerrors.h" +#include "pycore_object.h" // _PyType_HasFeature() +#include "pycore_pyerrors.h" // _PyErr_Occurred() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_unionobject.h" // _Py_union_type_or -#include "frameobject.h" -#include "pycore_frame.h" +#include "frameobject.h" // PyFrameObject +#include "pycore_frame.h" // InterpreterFrame #include "opcode.h" // MAKE_CELL #include "structmember.h" // PyMemberDef diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 0e3caf3..c7a014d 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -3,6 +3,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include #include diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index f91bb9f..d07ba38 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3,6 +3,7 @@ #include "Python.h" #include #include "pycore_ast.h" // _PyAST_Validate() +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_compile.h" // _PyAST_Compile() #include "pycore_object.h" // _Py_AddToAllObjects() #include "pycore_pyerrors.h" // _PyErr_NoMemory() diff --git a/Python/ceval.c b/Python/ceval.c index e9a9c1d..2d617a6 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -13,11 +13,11 @@ #include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_call.h" // _PyObject_FastCallDictTstate() #include "pycore_ceval.h" // _PyEval_SignalAsyncExc() -#include "pycore_code.h" +#include "pycore_code.h" // saturating_increment() #include "pycore_initconfig.h" // _PyStatus_OK() #include "pycore_long.h" // _PyLong_GetZero() #include "pycore_object.h" // _PyObject_GC_TRACK() -#include "pycore_moduleobject.h" +#include "pycore_moduleobject.h" // PyModuleObject #include "pycore_pyerrors.h" // _PyErr_Fetch() #include "pycore_pylifecycle.h" // _PyErr_Print() #include "pycore_pymem.h" // _PyMem_IsPtrFreed() diff --git a/Python/codecs.c b/Python/codecs.c index 9ee566b..b7c8db7 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -9,6 +9,7 @@ Copyright (c) Corporation for National Research Initiatives. ------------------------------------------------------------------------ */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_interp.h" // PyInterpreterState.codec_search_path #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI diff --git a/Python/errors.c b/Python/errors.c index 36a529e..f072c21 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -2,11 +2,12 @@ /* Error handling */ #include "Python.h" -#include "pycore_initconfig.h" -#include "pycore_pyerrors.h" -#include "pycore_pystate.h" // _PyThreadState_GET() -#include "pycore_sysmodule.h" -#include "pycore_traceback.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_initconfig.h" // _PyStatus_ERR() +#include "pycore_pyerrors.h" // _PyErr_Format() +#include "pycore_pystate.h" // _PyThreadState_GET() +#include "pycore_sysmodule.h" // _PySys_Audit() +#include "pycore_traceback.h" // _PyTraceBack_FromFrame() #ifndef __STDC__ #ifndef MS_WINDOWS diff --git a/Python/marshal.c b/Python/marshal.c index 530c8d0..c8a48a5 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -9,11 +9,12 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_code.h" // _PyCode_New() +#include "pycore_hashtable.h" // _Py_hashtable_t #include "longintrepr.h" #include "code.h" -#include "marshal.h" -#include "pycore_hashtable.h" -#include "pycore_code.h" // _PyCode_New() +#include "marshal.h" // Py_MARSHAL_VERSION /*[clinic input] module marshal diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 0154af0..ae3cbf1 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -15,21 +15,22 @@ Data members: */ #include "Python.h" +#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _Py_RecursionLimitLowerWaterMark() +#include "pycore_code.h" // _Py_QuickenedCount +#include "pycore_frame.h" // InterpreterFrame #include "pycore_initconfig.h" // _PyStatus_EXCEPTION() #include "pycore_object.h" // _PyObject_IS_GC() -#include "pycore_code.h" // _Py_QuickenedCount #include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0() #include "pycore_pyerrors.h" // _PyErr_Fetch() #include "pycore_pylifecycle.h" // _PyErr_WriteUnraisableDefaultHook() #include "pycore_pymem.h" // _PyMem_SetDefaultAllocator() #include "pycore_pystate.h" // _PyThreadState_GET() -#include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_structseq.h" // PyStructSequence_InitType() +#include "pycore_tuple.h" // _PyTuple_FromArray() #include "code.h" #include "frameobject.h" // PyFrame_GetBack() -#include "pycore_frame.h" #include "pydtrace.h" #include "osdefs.h" // DELIM #include "stdlib_module_names.h" // _Py_stdlib_module_names diff --git a/setup.py b/setup.py index 6122430..c6290ee 100644 --- a/setup.py +++ b/setup.py @@ -942,7 +942,8 @@ class PyBuildExt(build_ext): extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) # profiler (_lsprof is for cProfile.py) - self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'])) + self.add(Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'], + extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) # static Unicode character database self.add(Extension('unicodedata', ['unicodedata.c'], depends=['unicodedata_db.h', 'unicodename_db.h'], -- cgit v0.12