]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-85283: Add PySys_Audit() to the limited C API (#108571)
authorVictor Stinner <vstinner@python.org>
Tue, 17 Oct 2023 14:02:23 +0000 (16:02 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Oct 2023 14:02:23 +0000 (16:02 +0200)
The PySys_Audit() function was added in Python 3.8 by the PEP 578
"Python Runtime Audit Hooks".

Add also PySys_AuditTuple() to the limited C API, function added
to Python 3.13.

Move non-limited "PerfMap" C API from Include/sysmodule.h to
Include/cpython/sysmodule.h.

Doc/data/stable_abi.dat
Doc/whatsnew/3.13.rst
Include/cpython/sysmodule.h
Include/sysmodule.h
Lib/test/test_stable_abi_ctypes.py
Misc/NEWS.d/next/C API/2023-08-28-17-40-51.gh-issue-85283.raFNiD.rst [new file with mode: 0644]
Misc/stable_abi.toml
PC/python3dll.c

index 267d2b8c010cacd2ff06f5f70733975bcb3ad30e..811b1bd84d24174e068ec489cc16c4a24758c5e8 100644 (file)
@@ -606,6 +606,8 @@ function,PyStructSequence_NewType,3.2,,
 function,PyStructSequence_SetItem,3.2,,
 var,PyStructSequence_UnnamedField,3.11,,
 var,PySuper_Type,3.2,,
+function,PySys_Audit,3.13,,
+function,PySys_AuditTuple,3.13,,
 function,PySys_FormatStderr,3.2,,
 function,PySys_FormatStdout,3.2,,
 function,PySys_GetObject,3.2,,
index 0ff5f4321944f9a721a9c5ed7ab00b72230dfda4..42e059386e2b8cd2cf6ae33d7b571769d5c5ea76 100644 (file)
@@ -1059,6 +1059,11 @@ New Features
   (version 3.13).
   (Contributed by Victor Stinner in :gh:`85283`.)
 
+* Add :c:func:`PySys_Audit` and :c:func:`PySys_AuditTuple` functions to the
+  limited C API.
+  (Contributed by Victor Stinner in :gh:`85283`.)
+
+
 Porting to Python 3.13
 ----------------------
 
index 36c4f89432067bf35171833c96cefd4f19da14a1..df12ae440f024be10afdcb62ae300bce9077d856 100644 (file)
@@ -10,6 +10,14 @@ PyAPI_FUNC(int) PySys_Audit(
     ...);
 PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
 
-PyAPI_FUNC(int) PySys_AuditTuple(
-    const char *event,
-    PyObject *args);
+typedef struct {
+    FILE* perf_map;
+    PyThread_type_lock map_lock;
+} PerfMapState;
+
+PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
+PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(
+    const void *code_addr,
+    unsigned int code_size,
+    const char *entry_name);
+PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);
index 225e0602d191e1ae8d684131c06f4a46b18d9280..7406513ec1439ab3912bd71946711bde7d6857c7 100644 (file)
@@ -21,17 +21,15 @@ Py_DEPRECATED(3.13) PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
 
 PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);
 
-#if !defined(Py_LIMITED_API)
-typedef struct {
-    FILE* perf_map;
-    PyThread_type_lock map_lock;
-} PerfMapState;
-
-PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
-
-PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name);
-
-PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
+PyAPI_FUNC(int) PySys_Audit(
+    const char *event,
+    const char *argFormat,
+    ...);
+
+PyAPI_FUNC(int) PySys_AuditTuple(
+    const char *event,
+    PyObject *args);
 #endif
 
 #ifndef Py_LIMITED_API
index 0c831c4f478a61e38e444dcaed7dc63589b0e45b..6d5353c22764df1342db4df2745a496b462116e2 100644 (file)
@@ -626,6 +626,8 @@ SYMBOL_NAMES = (
     "PySys_AddWarnOption",
     "PySys_AddWarnOptionUnicode",
     "PySys_AddXOption",
+    "PySys_Audit",
+    "PySys_AuditTuple",
     "PySys_FormatStderr",
     "PySys_FormatStdout",
     "PySys_GetObject",
diff --git a/Misc/NEWS.d/next/C API/2023-08-28-17-40-51.gh-issue-85283.raFNiD.rst b/Misc/NEWS.d/next/C API/2023-08-28-17-40-51.gh-issue-85283.raFNiD.rst
new file mode 100644 (file)
index 0000000..45ffda3
--- /dev/null
@@ -0,0 +1,2 @@
+Add the :c:func:`PySys_Audit` function to the limited C API. Patch by Victor
+Stinner.
index f8ee973612e7ef18030b7367cd9bae94a084a16c..75c260c8f1b2be869ed34d07dbddfa674e98258a 100644 (file)
     added = '3.13'
 [function.PyMem_RawFree]
     added = '3.13'
+[function.PySys_Audit]
+    added = '3.13'
+[function.PySys_AuditTuple]
+    added = '3.13'
index dd3be3a7490b99cc87364f5b1ae59aa589940249..d12889f44d65b60262ab5ec8f9b0f802581c1a27 100755 (executable)
@@ -568,6 +568,8 @@ EXPORT_FUNC(PyStructSequence_SetItem)
 EXPORT_FUNC(PySys_AddWarnOption)
 EXPORT_FUNC(PySys_AddWarnOptionUnicode)
 EXPORT_FUNC(PySys_AddXOption)
+EXPORT_FUNC(PySys_Audit)
+EXPORT_FUNC(PySys_AuditTuple)
 EXPORT_FUNC(PySys_FormatStderr)
 EXPORT_FUNC(PySys_FormatStdout)
 EXPORT_FUNC(PySys_GetObject)