8000 gh-85283: Add PySys_Audit() to the limited C API · python/cpython@cf09536 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit cf09536

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". Add also PySys_AuditTuple() to the limited C API, function added to Python 3.13. Move also non-limited "PerfMap" C API from Include/sysmodule.h to Include/cpython/sysmodule.h.
1 parent 78e4a6d commit cf09536

File tree

8 files changed

+37
-14
lines changed

8 files changed

+37
-14
lines changed

Doc/data/stable_abi.dat

Lines changed: 2 additions & 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,11 @@ New Features
10581058
(version 3.13).
10591059
(Contributed by Victor Stinner in :gh:`85283`.)
10601060

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

Include/cpython/sysmodule.h

Lines changed: 11 additions & 3 deletions
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

Lines changed: 9 additions & 11 deletions
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

Lines changed: 2 additions & 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: 4 additions & 0 deletions
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

Lines changed: 2 additions & 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)
0