Skip to content

Commit 8b5bf44

Browse files
committed
gh-85283: Add PySys_Audit() to the limited C API
This function was added in Python 3.8 by the PEP 578 "Python Runtime Audit Hooks". It is needed to convert some stdlib extensions to the limited C API, like fcntl, resource and syslog. Move also non-limited "PerfMap" C API from Include/sysmodule.h to Include/cpython/sysmodule.h.
1 parent cd2ef21 commit 8b5bf44

File tree

8 files changed

+27
-15
lines changed

8 files changed

+27
-15
lines changed

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,10 @@ New Features
924924
references) now supports the :ref:`Limited API <limited-c-api>`.
925925
(Contributed by Victor Stinner in :gh:`108634`.)
926926

927+
* Add :c:func:`PySys_Audit` function to the limited C API.
928+
(Contributed by Victor Stinner in :gh:`85283`.)
929+
930+
927931
Porting to Python 3.13
928932
----------------------
929933

Include/cpython/sysmodule.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44

55
typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
66

7-
PyAPI_FUNC(int) PySys_Audit(
8-
const char *event,
9-
const char *argFormat,
10-
...);
117
PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
8+
9+
typedef struct {
10+
FILE* perf_map;
11+
PyThread_type_lock map_lock;
12+
} PerfMapState;
13+
14+
PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
15+
16+
PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name);
17+
18+
PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);

Include/sysmodule.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ 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+
...);
3529
#endif
3630

3731
#ifndef Py_LIMITED_API

Lib/test/test_stable_abi_ctypes.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,3 +2452,5 @@
24522452
added = '3.13'
24532453
[function.PyLong_AsInt]
24542454
added = '3.13'
2455+
[function.PySys_Audit]
2456+
added = '3.13'

PC/python3dll.c

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)