]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106320: Remove private _PySys functions (#108452)
authorVictor Stinner <vstinner@python.org>
Thu, 24 Aug 2023 20:02:09 +0000 (22:02 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Aug 2023 20:02:09 +0000 (20:02 +0000)
Move private functions to the internal C API (pycore_sysmodule.h):

* _PySys_GetAttr()
* _PySys_GetSizeOf()

No longer export most of these functions.

Fix also a typo in Include/cpython/optimizer.h: add a missing space.

12 files changed:
Include/cpython/optimizer.h
Include/cpython/sysmodule.h
Include/internal/pycore_sysmodule.h
Modules/_io/bytesio.c
Modules/_pickle.c
Modules/_threadmodule.c
Modules/faulthandler.c
Python/_warnings.c
Python/bltinmodule.c
Python/intrinsics.c
Python/sysmodule.c
Python/traceback.c

index e3fe0e8f0ffd5993e2125fbddd7f35b57e745a92..10457afc180a003decf76df79a3515dcee2ae01c 100644 (file)
@@ -38,7 +38,7 @@ PyAPI_FUNC(void) PyUnstable_SetOptimizer(_PyOptimizerObject* optimizer);
 
 PyAPI_FUNC(_PyOptimizerObject *) PyUnstable_GetOptimizer(void);
 
-PyAPI_FUNC(_PyExecutorObject *)PyUnstable_GetExecutor(PyCodeObject *code, int offset);
+PyAPI_FUNC(_PyExecutorObject *) PyUnstable_GetExecutor(PyCodeObject *code, int offset);
 
 struct _PyInterpreterFrame *
 _PyOptimizer_BackEdge(struct _PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNIT *dest, PyObject **stack_pointer);
index 19d9dddc344a4f0ee4fb0d849b82f280e3000ca3..e028fb7ecd52307d06160ae547d0295962b40914 100644 (file)
@@ -2,11 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-PyAPI_FUNC(PyObject *) _PySys_GetAttr(PyThreadState *tstate,
-                                      PyObject *name);
-
-PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
-
 typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
 
 PyAPI_FUNC(int) PySys_Audit(
index aec9c2060fd0c093349c6a5466c502aa68859931..9b8eafd3d6cfd3f467709ff338466895a460bc23 100644 (file)
@@ -8,6 +8,12 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+// Export for '_pickle' shared extension
+PyAPI_FUNC(PyObject*) _PySys_GetAttr(PyThreadState *tstate, PyObject *name);
+
+// Export for '_pickle' shared extension
+PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
+
 extern int _PySys_Audit(
     PyThreadState *tstate,
     const char *event,
index 3ab503c9e3998d96ae0ff69771783571e9eefb48..f3074203f54ea2aa8864e819b153b765a9f7cb65 100644 (file)
@@ -1,5 +1,7 @@
 #include "Python.h"
 #include "pycore_object.h"
+#include "pycore_sysmodule.h"     // _PySys_GetSizeOf()
+
 #include <stddef.h>               // offsetof()
 #include "_iomodule.h"
 
index 4f26ffe27d75f1fe416abef75e9c02f106672e63..b97524856eeca82ad1e8c54bd4e954913f5a0645 100644 (file)
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_setobject.h"     // _PySet_NextEntry()
-
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
 
 #include <stdlib.h>               // strtol()
 
+
 PyDoc_STRVAR(pickle_module_doc,
 "Optimized C implementation for the Python pickle module.");
 
index 229abfba82d1ada2df1851644b886238ce3f3424..2cf866c5a114160ceca686efa3d3043754e28149 100644 (file)
@@ -9,6 +9,7 @@
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
 #include "pycore_pylifecycle.h"
 #include "pycore_pystate.h"       // _PyThreadState_SetCurrent()
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
 #include "pycore_weakref.h"       // _PyWeakref_GET_REF()
 
 #include <stddef.h>               // offsetof()
index d8cfc13a7dc6d504580293de049ff055bd136907..5ec34d4e99c80d609816a4bbbc59b0d12ab369b1 100644 (file)
@@ -3,6 +3,7 @@
 #include "pycore_pyerrors.h"      // _Py_DumpExtensionModules
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_signal.h"        // Py_NSIG
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
 #include "pycore_traceback.h"     // _Py_DumpTracebackThreads
 
 #include <object.h>
index 40ec5f613d5bf469f8179992f01f00eacd865dc9..9e562d7ba7f6a7e23d4d7c1a028a5a4d7d97c146 100644 (file)
@@ -7,6 +7,8 @@
 #include "pycore_pyerrors.h"
 #include "pycore_pylifecycle.h"   // _Py_IsInterpreterFinalizing()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
+
 #include "clinic/_warnings.c.h"
 
 #define MODULE_NAME "_warnings"
index 787f53fae354dbc4f2b907fa9ac14c45fbe33ef2..ac9bc72fe80d6c12d8c0e977727d2cf9eb196a33 100644 (file)
@@ -12,6 +12,7 @@
 #include "pycore_object.h"        // _Py_AddToAllObjects()
 #include "pycore_pyerrors.h"      // _PyErr_NoMemory()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
 #include "pycore_tuple.h"         // _PyTuple_FromArray()
 
 #include "clinic/bltinmodule.c.h"
index 5267c10238e6269bb755f73a4fb9a865901d2c04..fefee0fc4ebbec2b322b60dee75ea39b2f3c3b0f 100644 (file)
@@ -4,10 +4,11 @@
 #include "Python.h"
 #include "pycore_frame.h"
 #include "pycore_function.h"
-#include "pycore_runtime.h"
 #include "pycore_global_objects.h"
 #include "pycore_intrinsics.h"
 #include "pycore_pyerrors.h"
+#include "pycore_runtime.h"
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
 #include "pycore_typevarobject.h"
 
 
index 94d0f01f7477a7062ee75e85f907f993ae1e40d2..0ec763c7aa7cf853d7eca8f996e07d5fb561dd6c 100644 (file)
@@ -31,6 +31,7 @@ Data members:
 #include "pycore_pymem.h"         // _PyMem_SetDefaultAllocator()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_structseq.h"     // _PyStructSequence_InitBuiltinWithFlags()
+#include "pycore_sysmodule.h"     // Define _PySys_GetSizeOf()
 #include "pycore_tuple.h"         // _PyTuple_FromArray()
 
 #include "frameobject.h"          // PyFrame_FastToLocalsWithError()
index 61ace38275355cc47f647dfa7b87baee439447ca..657ddab1cbf615528f44b80e4e81731c3861a3eb 100644 (file)
@@ -13,6 +13,7 @@
 #include "pycore_pyarena.h"       // _PyArena_Free()
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_sysmodule.h"     // _PySys_GetAttr()
 #include "pycore_traceback.h"     // EXCEPTION_TB_HEADER
 
 #include "../Parser/pegen.h"      // _PyPegen_byte_offset_to_character_offset()