Skip to content

Commit ee520a1

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 4116592 commit ee520a1

File tree

8 files changed

+25
-16
lines changed

8 files changed

+25
-16
lines changed

Doc/data/stable_abi.dat

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

Doc/whatsnew/3.13.rst

+3
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,9 @@ New Features
886886
(with an underscore prefix).
887887
(Contributed by Victor Stinner in :gh:`108014`.)
888888

889+
* Add :c:func:`PySys_Audit` function to the limited C API.
890+
(Contributed by Victor Stinner in :gh:`85283`.)
891+
889892
Porting to Python 3.13
890893
----------------------
891894

Include/cpython/sysmodule.h

+11-4
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

+4-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,10 @@ 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);
35-
#endif
24+
PyAPI_FUNC(int) PySys_Audit(
25+
const char *event,
26+
const char *argFormat,
27+
...);
3628

3729
#ifndef Py_LIMITED_API
3830
# define Py_CPYTHON_SYSMODULE_H

Lib/test/test_stable_abi_ctypes.py

+1
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

+2
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

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

0 commit comments

Comments
 (0)