]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-107211: No longer export internal functions (4) (#107217)
authorVictor Stinner <vstinner@python.org>
Tue, 25 Jul 2023 03:16:28 +0000 (05:16 +0200)
committerGitHub <noreply@github.com>
Tue, 25 Jul 2023 03:16:28 +0000 (03:16 +0000)
No longer export these 2 internal C API functions:

* _PyEval_SignalAsyncExc()
* _PyEval_SignalReceived()

Add also comments explaining why some internal functions have to be
exported, and update existing comments.

13 files changed:
Include/internal/pycore_atexit.h
Include/internal/pycore_ceval.h
Include/internal/pycore_code.h
Include/internal/pycore_initconfig.h
Include/internal/pycore_interp.h
Include/internal/pycore_interp_id.h
Include/internal/pycore_namespace.h
Include/internal/pycore_object.h
Include/internal/pycore_pathconfig.h
Include/internal/pycore_pylifecycle.h
Include/internal/pycore_pymem.h
Include/internal/pycore_structseq.h
Include/internal/pycore_typeobject.h

index fc5cb6d8826435a62575d080f369f36689eea83b..3966df70e2616fb4d7349b28975846be871eaacd 100644 (file)
@@ -51,6 +51,7 @@ struct atexit_state {
     int callback_len;
 };
 
+// Export for '_xxinterpchannels' shared extension
 PyAPI_FUNC(int) _Py_AtExit(
     PyInterpreterState *interp,
     atexit_datacallbackfunc func,
index ea5b99ebba07bab800334fbdaeeba5074215bafd..05b7380597812bdb06399f18e9cb5eaab9d64699 100644 (file)
@@ -23,13 +23,14 @@ struct _ceval_runtime_state;
 extern void _Py_FinishPendingCalls(PyThreadState *tstate);
 extern void _PyEval_InitState(PyInterpreterState *, PyThread_type_lock);
 extern void _PyEval_FiniState(struct _ceval_state *ceval);
-PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
+extern void _PyEval_SignalReceived(PyInterpreterState *interp);
+// Export for '_testinternalcapi' shared extension
 PyAPI_FUNC(int) _PyEval_AddPendingCall(
     PyInterpreterState *interp,
     int (*func)(void *),
     void *arg,
     int mainthreadonly);
-PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
+extern void _PyEval_SignalAsyncExc(PyInterpreterState *interp);
 #ifdef HAVE_FORK
 extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
 #endif
@@ -122,6 +123,7 @@ static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
 }
 #endif
 
+// Export for _Py_EnterRecursiveCall()
 PyAPI_FUNC(int) _Py_CheckRecursiveCall(
     PyThreadState *tstate,
     const char *where);
index 62a943b115f9e2727952f2a77f3329d6aad8c826..bcdf8645c8557c3089bbf69011e3c596219dc0f5 100644 (file)
@@ -262,7 +262,6 @@ extern int _PyStaticCode_Init(PyCodeObject *co);
 
 #ifdef Py_STATS
 
-
 #define STAT_INC(opname, name) do { if (_py_stats) _py_stats->opcode_stats[opname].specialization.name++; } while (0)
 #define STAT_DEC(opname, name) do { if (_py_stats) _py_stats->opcode_stats[opname].specialization.name--; } while (0)
 #define OPCODE_EXE_INC(opname) do { if (_py_stats) _py_stats->opcode_stats[opname].execution_count++; } while (0)
@@ -274,7 +273,7 @@ extern int _PyStaticCode_Init(PyCodeObject *co);
 #define EVAL_CALL_STAT_INC_IF_FUNCTION(name, callable) \
     do { if (_py_stats && PyFunction_Check(callable)) _py_stats->call_stats.eval_calls[name]++; } while (0)
 
-// Export for stdlib '_opcode' shared extension
+// Export for '_opcode' shared extension
 PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
 
 #else
index 67ca8cae3a73b25a50dd39cc7d211135c3eacfb0..0945bb0936f0393ea57c10faf1f8426e778effa1 100644 (file)
@@ -122,6 +122,7 @@ extern PyStatus _PyPreCmdline_Read(_PyPreCmdline *cmdline,
 
 /* --- PyPreConfig ----------------------------------------------- */
 
+// Export for '_testembed' program
 PyAPI_FUNC(void) _PyPreConfig_InitCompatConfig(PyPreConfig *preconfig);
 extern void _PyPreConfig_InitFromConfig(
     PyPreConfig *preconfig,
@@ -146,6 +147,7 @@ typedef enum {
     _PyConfig_INIT_ISOLATED = 3
 } _PyConfigInitEnum;
 
+// Export for '_testembed' program
 PyAPI_FUNC(void) _PyConfig_InitCompatConfig(PyConfig *config);
 extern PyStatus _PyConfig_Copy(
     PyConfig *config,
index 260614e937370f599bde03e72df201b8c6948844..522ce4a80ecc292b31cf4f4594f9d88c5fea78d2 100644 (file)
@@ -238,6 +238,7 @@ extern int _PyInterpreterState_IDInitref(PyInterpreterState *);
 extern int _PyInterpreterState_IDIncref(PyInterpreterState *);
 extern void _PyInterpreterState_IDDecref(PyInterpreterState *);
 
+// Export for '_xxsubinterpreters' shared extension
 PyAPI_FUNC(PyObject*) _PyInterpreterState_GetMainModule(PyInterpreterState *);
 
 extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
@@ -253,7 +254,9 @@ extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp)
    The caller must hold the GIL.
 
    Once done with the configuration, PyConfig_Clear() must be called to clear
-   it. */
+   it.
+
+   Export for '_testinternalcapi' shared extension. */
 PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
     struct PyConfig *config);
 
@@ -271,7 +274,9 @@ PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
 
    Return 0 on success. Raise an exception and return -1 on error.
 
-   The configuration should come from _PyInterpreterState_GetConfigCopy(). */
+   The configuration should come from _PyInterpreterState_GetConfigCopy().
+
+   Export for '_testinternalcapi' shared extension. */
 PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
     const struct PyConfig *config);
 
index 34c96df98ef73078bcb2953695e7273588d7c097..8c6f8315cac391f4addb0b31e7d3a1a9f5b7c332 100644 (file)
@@ -10,16 +10,16 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-// Export for the _xxsubinterpreters shared extension
+// Export for '_xxsubinterpreters' shared extension
 PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
 
-// Export for the _xxsubinterpreters shared extension
+// Export for '_xxsubinterpreters' shared extension
 PyAPI_FUNC(PyObject*) _PyInterpreterID_New(int64_t);
 
-// Export for the _xxinterpchannels shared extension
+// Export for '_xxinterpchannels' shared extension
 PyAPI_FUNC(PyObject*) _PyInterpreterState_GetIDObject(PyInterpreterState *);
 
-// Export for the _testinternalcapi shared extension
+// Export for '_testinternalcapi' shared extension
 PyAPI_FUNC(PyInterpreterState*) _PyInterpreterID_LookUp(PyObject *);
 
 #ifdef __cplusplus
index 94235471265e14d80110362ba8408f52ed7d5635..f165cf15319a599b1aab816a6a7bca128159a6a9 100644 (file)
@@ -12,6 +12,7 @@ extern "C" {
 
 extern PyTypeObject _PyNamespace_Type;
 
+// Export for '_testmultiphase' shared extension
 PyAPI_FUNC(PyObject*) _PyNamespace_New(PyObject *kwds);
 
 #ifdef __cplusplus
index c65c21c3e77fba5e32a0fa8ef52596ed875981bc..6bf9dc245d5de43e154aed34b01e32dd2a5827c6 100644 (file)
@@ -434,7 +434,8 @@ extern PyObject ** _PyObject_ComputedDictPointer(PyObject *);
 extern void _PyObject_FreeInstanceAttributes(PyObject *obj);
 extern int _PyObject_IsInstanceDictEmpty(PyObject *);
 
-PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, PyObject *);
+// Export for 'math' shared extension
+PyAPI_FUNC(PyObject*) _PyObject_LookupSpecial(PyObject *, PyObject *);
 
 extern int _PyObject_IsAbstract(PyObject *);
 
index b8deaa0c3eb067b14f2bb2bcca40f5fd960feb06..729f3e09ce1ca49366d1dbf0eb840ce71cd44812 100644 (file)
@@ -8,6 +8,7 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+// Export for '_testinternalcapi' shared extension
 PyAPI_FUNC(void) _PyPathConfig_ClearGlobal(void);
 extern PyStatus _PyPathConfig_ReadGlobal(PyConfig *config);
 extern PyStatus _PyPathConfig_UpdateGlobal(const PyConfig *config);
index fb28652515909d3cea496e19fa07707a2f201294..b4d5b1f1239e1db2fcfa3bee2d2facea36e05c3b 100644 (file)
@@ -103,6 +103,7 @@ PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
 
 /* Random */
 extern int _PyOS_URandom(void *buffer, Py_ssize_t size);
+// Export for '_random' shared extension
 PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
 
 /* Legacy locale support */
index 017a60abc63627695e20e1f08318a67334c73760..6b5113714dbeb28f0cd7d6bc042ea620a06ce3a1 100644 (file)
@@ -10,14 +10,14 @@ extern "C" {
 
 // Try to get the allocators name set by _PyMem_SetupAllocators().
 // Return NULL if unknown.
-// Export for shared _testinternalcapi extension.
+// Export for '_testinternalcapi' shared extension.
 PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
 
 // strdup() using PyMem_RawMalloc()
 extern char* _PyMem_RawStrdup(const char *str);
 
 // strdup() using PyMem_Malloc().
-// Export for shared _pickle extension.
+// Export for '_pickle ' shared extension.
 PyAPI_FUNC(char*) _PyMem_Strdup(const char *str);
 
 // wcsdup() using PyMem_RawMalloc()
index 6f5dfc12707cf8d69724e4edde6352dd3dce7dec..5cff165627502bd865abda793c469c4eeb01f588 100644 (file)
@@ -11,7 +11,8 @@ extern "C" {
 
 /* other API */
 
-PyAPI_FUNC(PyTypeObject *) _PyStructSequence_NewType(
+// Export for '_curses' shared extension
+PyAPI_FUNC(PyTypeObject*) _PyStructSequence_NewType(
     PyStructSequence_Desc *desc,
     unsigned long tp_flags);
 
index bf32667f8e36ec2fa24ba329674a655ddcff5043..2ad2adad0aa41262ab21add777d53965d44af514 100644 (file)
@@ -114,7 +114,7 @@ extern static_builtin_state * _PyStaticType_GetState(PyInterpreterState *, PyTyp
 extern void _PyStaticType_ClearWeakRefs(PyInterpreterState *, PyTypeObject *type);
 extern void _PyStaticType_Dealloc(PyInterpreterState *, PyTypeObject *);
 
-// Export for 'math' shared extension
+// Export for 'math' shared extension via _PyType_IsReady() function
 PyAPI_FUNC(PyObject *) _PyType_GetDict(PyTypeObject *);
 extern PyObject * _PyType_GetBases(PyTypeObject *type);
 extern PyObject * _PyType_GetMRO(PyTypeObject *type);