Skip to content

Commit 2324652

Browse files
authored
gh-85283: Add PySys_Audit() to the limited C API (#108571)
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.
1 parent 6db6b30 commit 2324652

File tree

8 files changed

+37
-14
lines changed

8 files changed

+37
-14
lines changed

Doc/data/stable_abi.dat

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.13.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,11 @@ New Features
10591059
(version 3.13).
10601060
(Contributed by Victor Stinner in :gh:`85283`.)
10611061

1062+
* Add :c:func:`PySys_Audit` and :c:func:`PySys_AuditTuple` functions to the
1063+
limited C API.
1064+
(Contributed by Victor Stinner in :gh:`85283`.)
1065+
1066+
10621067
Porting to Python 3.13
10631068
----------------------
10641069

Include/cpython/sysmodule.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ PyAPI_FUNC(int) PySys_Audit(
1010
...);
1111
PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
1212

13-
PyAPI_FUNC(int) PySys_AuditTuple(
14-
const char *event,
15-
PyObject *args);
13+
typedef struct {
14+
FILE* perf_map;
15+
PyThread_type_lock map_lock;
16+
} PerfMapState;
17+
18+
PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
19+
PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(
20+
const void *code_addr,
21+
unsigned int code_size,
22+
const char *entry_name);
23+
PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);

Include/sysmodule.h

+9-11
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ Py_DEPRECATED(3.13) PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
2121

2222
PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);
2323

24-
#if !defined(Py_LIMITED_API)
25-
typedef struct {
26-
FILE* perf_map;
27-
PyThread_type_lock map_lock;
28-
} PerfMapState;
29-
30-
PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
31-
32-
PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name);
33-
34-
PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);
24+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
25+
PyAPI_FUNC(int) PySys_Audit(
26+
const char *event,
27+
const char *argFormat,
28+
...);
29+
30+
PyAPI_FUNC(int) PySys_AuditTuple(
31+
const char *event,
32+
PyObject *args);
3533
#endif
3634

3735
#ifndef Py_LIMITED_API

Lib/test/test_stable_abi_ctypes.py

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add the :c:func:`PySys_Audit` function to the limited C API. Patch by Victor
2+
Stinner.

Misc/stable_abi.toml

+4
Original file line numberDiff line numberDiff line change
@@ -2474,3 +2474,7 @@
24742474
added = '3.13'
24752475
[function.PyMem_RawFree]
24762476
added = '3.13'
2477+
[function.PySys_Audit]
2478+
added = '3.13'
2479+
[function.PySys_AuditTuple]
2480+
added = '3.13'

PC/python3dll.c

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)