8000 gh-107211: No longer export internal functions (4) (#107217) · python/cpython@c5b13d6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c5b13d6

Browse files
authored
gh-107211: No longer export internal functions (4) (#107217)
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.
1 parent 0d0520a commit c5b13d6

13 files changed

+29
-15
lines changed

Include/internal/pycore_atexit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct atexit_state {
5151
int callback_len;
5252
};
5353

54+
// Export for '_xxinterpchannels' shared extension
5455
PyAPI_FUNC(int) _Py_AtExit(
5556
PyInterpreterState *interp,
5657
atexit_datacallbackfunc func,

Include/internal/pycore_ceval.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ struct _ceval_runtime_state;
2323
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
2424
extern void _PyEval_InitState(PyInterpreterState *, PyThread_type_lock);
2525
extern void _PyEval_FiniState(struct _ceval_state *ceval);
26-
PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
26+
extern void _PyEval_SignalReceived(PyInterpreterState *interp);
27+
// Export for '_testinternalcapi' shared extension
2728
PyAPI_FUNC(int) _PyEval_AddPendingCall(
2829
PyInterpreterState *interp,
2930
int (*func)(void *),
3031
void *arg,
3132
int mainthreadonly);
32-
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
33+
extern void _PyEval_SignalAsyncExc(PyInterpreterState *interp);
3334
#ifdef HAVE_FORK
3435
extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
3536
#endif
@@ -122,6 +123,7 @@ static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
122123
}
123124
#endif
124125

126+
// Export for _Py_EnterRecursiveCall()
125127
PyAPI_FUNC(int) _Py_CheckRecursiveCall(
126128
PyThreadState *tstate,
127129
const char *where);

Include/internal/pycore_code.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ extern int _PyStaticCode_Init(PyCodeObject *co);
262262

263263
#ifdef Py_STATS
264264

265-
266265
#define STAT_INC(opname, name) do { if (_py_stats) _py_stats->opcode_stats[opname].specialization.name++; } while (0)
267266
#define STAT_DEC(opname, name) do { if (_py_stats) _py_stats->opcode_stats[opname].specialization.name--; } while (0)
268267
#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);
274273
#define EVAL_CALL_STAT_INC_IF_FUNCTION(name, callable) \
275274
do { if (_py_stats && PyFunction_Check(callable)) _py_stats->call_stats.eval_calls[name]++; } while (0)
276275

277-
// Export for stdlib '_opcode' shared extension
276+
// Export for '_opcode' shared extension
278277
PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
279278

280279
#else

Include/internal/pycore_initconfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ extern PyStatus _PyPreCmdline_Read(_PyPreCmdline *cmdline,
122122

123123
/* --- PyPreConfig ----------------------------------------------- */
124124

125+
// Export for '_testembed' program
125126
PyAPI_FUNC(void) _PyPreConfig_InitCompatConfig(PyPreConfig *preconfig);
126127
extern void _PyPreConfig_InitFromConfig(
127128
PyPreConfig *preconfig,
@@ -146,6 +147,7 @@ typedef enum {
146147
_PyConfig_INIT_ISOLATED = 3
147148
} _PyConfigInitEnum;
148149

150+
// Export for '_testembed' program
149151
PyAPI_FUNC(void) _PyConfig_InitCompatConfig(PyConfig *config);
150152
extern PyStatus _PyConfig_Copy(
151153
PyConfig *config,

Include/internal/pycore_interp.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ extern int _PyInterpreterState_IDInitref(PyInterpreterState *);
238238
extern int _PyInterpreterState_IDIncref(PyInterpreterState *);
239239
extern void _PyInterpreterState_IDDecref(PyInterpreterState *);
240240

241+
// Export for '_xxsubinterpreters' shared extension
241242
PyAPI_FUNC(PyObject*) _PyInterpreterState_GetMainModule(PyInterpreterState *);
242243

243244
extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
@@ -253,7 +254,9 @@ extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp)
253254
The caller must hold the GIL.
254255
255256
Once done with the configuration, PyConfig_Clear() must be called to clear
256-
it. */
257+
it.
258+
259+
Export for '_testinternalcapi' shared extension. */
257260
PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
258261
struct PyConfig *config);
259262

@@ -271,7 +274,9 @@ PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
271274
272275
Return 0 on success. Raise an exception and return -1 on error.
273276
274-
The configuration should come from _PyInterpreterState_GetConfigCopy(). */
277+
The configuration should come from _PyInterpreterState_GetConfigCopy().
278+
279+
Export for '_testinternalcapi' shared extension. */
275280
PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
276281
const struct PyConfig *config);
277282

Include/internal/pycore_interp_id.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ extern "C" {
1010
# error "this header requires Py_BUILD_CORE define"
1111
#endif
1212

13-
// Export for the _xxsubinterpreters shared extension
13+
// Export for '_xxsubinterpreters' shared extension
1414
PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
1515

16-
// Export for the _xxsubinterpreters shared extension
16+
// Export for '_xxsubinterpreters' shared extension
1717
PyAPI_FUNC(PyObject*) _PyInterpreterID_New(int64_t);
1818

19-
// Export for the _xxinterpchannels shared extension
19+
// Export for '_xxinterpchannels' shared extension
2020
PyAPI_FUNC(PyObject*) _PyInterpreterState_GetIDObject(PyInterpreterState *);
2121

22-
// Export for the _testinternalcapi shared extension
22+
// Export for '_testinternalcapi' shared extension
2323
PyAPI_FUNC(PyInterpreterState*) _PyInterpreterID_LookUp(PyObject *);
2424

2525
#ifdef __cplusplus

Include/internal/pycore_namespace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extern "C" {
1212

1313
extern PyTypeObject _PyNamespace_Type;
1414

15+
// Export for '_testmultiphase' shared extension
1516
PyAPI_FUNC(PyObject*) _PyNamespace_New(PyObject *kwds);
1617

1718
#ifdef __cplusplus

Include/internal/pycore_object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ extern PyObject ** _PyObject_ComputedDictPointer(PyObject *);
434434
extern void _PyObject_FreeInstanceAttributes(PyObject *obj);
435435
extern int _PyObject_IsInstanceDictEmpty(PyObject *);
436436

437-
PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, PyObject *);
437+
// Export for 'math' shared extension
438+
PyAPI_FUNC(PyObject*) _PyObject_LookupSpecial(PyObject *, PyObject *);
438439

439440
extern int _PyObject_IsAbstract(PyObject *);
440441

Include/internal/pycore_pathconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
// Export for '_testinternalcapi' shared extension
1112
PyAPI_FUNC(void) _PyPathConfig_ClearGlobal(void);
1213
extern PyStatus _PyPathConfig_ReadGlobal(PyConfig *config);
1314
extern PyStatus _PyPathConfig_UpdateGlobal(const PyConfig *config);

Include/internal/pycore_pylifecycle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
103103

104104
/* Random */
105105
extern int _PyOS_URandom(void *buffer, Py_ssize_t size);
106+
// Export for '_random' shared extension
106107
PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
107108

108109
/* Legacy locale support */

Include/internal/pycore_pymem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ extern "C" {
1010

1111
// Try to get the allocators name set by _PyMem_SetupAllocators().
1212
// Return NULL if unknown.
13-
// Export for shared _testinternalcapi extension.
13+
// Export for '_testinternalcapi' shared extension.
1414
PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
1515

1616
// strdup() using PyMem_RawMalloc()
1717
extern char* _PyMem_RawStrdup(const char *str);
1818

1919
// strdup() using PyMem_Malloc().
20-
// Export for shared _pickle extension.
20+
// Export for '_pickle ' shared extension.
2121
PyAPI_FUNC(char*) _PyMem_Strdup(const char *str);
2222

2323
// wcsdup() using PyMem_RawMalloc()

Include/internal/pycore_structseq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ extern "C" {
1111

1212
/* other API */
1313

14-
PyAPI_FUNC(PyTypeObject *) _PyStructSequence_NewType(
14+
// Export for '_curses' shared extension
15+
PyAPI_FUNC(PyTypeObject*) _PyStructSequence_NewType(
1516
PyStructSequence_Desc *desc,
1617
unsigned long tp_flags);
1718

Include/internal/pycore_typeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ extern static_builtin_state * _PyStaticType_GetState(PyInterpreterState *, PyTyp
114114
extern void _PyStaticType_ClearWeakRefs(PyInterpreterState *, PyTypeObject *type);
115115
extern void _PyStaticType_Dealloc(PyInterpreterState *, PyTypeObject *);
116116

117-
// Export for 'math' shared extension
117+
// Export for 'math' shared extension via _PyType_IsReady() function
118118
PyAPI_FUNC(PyObject *) _PyType_GetDict(PyTypeObject *);
119119
extern PyObject * _PyType_GetBases(PyTypeObject *type);
120120
extern PyObject * _PyType_GetMRO(PyTypeObject *type);

0 commit comments

Comments
 (0)
0