Skip to content

Commit e563a15

Browse files
terryjreedyzooba
authored andcommitted
bpo-38892: Improve docs for audit event (GH-17361)
1 parent bc441ed commit e563a15

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Doc/c-api/sys.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ accessible to C code. They all work with the current interpreter thread's
309309
310310
.. c:function:: int PySys_Audit(const char *event, const char *format, ...)
311311
312-
Raises an auditing event with any active hooks. Returns zero for success
312+
Raise an auditing event with any active hooks. Return zero for success
313313
and non-zero with an exception set on failure.
314314
315315
If any hooks have been added, *format* and other arguments will be used
@@ -327,11 +327,16 @@ accessible to C code. They all work with the current interpreter thread's
327327
328328
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
329329
330-
Adds to the collection of active auditing hooks. Returns zero for success
331-
and non-zero on failure. If the runtime has been initialized, also sets an
330+
Append the callable *hook* to the list of active auditing hooks.
331+
Return zero for success
332+
and non-zero on failure. If the runtime has been initialized, also set an
332333
error on failure. Hooks added through this API are called for all
333334
interpreters created by the runtime.
334335
336+
The *userData* pointer is passed into the hook function. Since hook
337+
functions may be called from different runtimes, this pointer should not
338+
refer directly to Python state.
339+
335340
This function is safe to call before :c:func:`Py_Initialize`. When called
336341
after runtime initialization, existing audit hooks are notified and may
337342
silently abort the operation by raising an error subclassed from
@@ -342,14 +347,10 @@ accessible to C code. They all work with the current interpreter thread's
342347
:c:type:`PyTupleObject`. The hook function is always called with the GIL
343348
held by the Python interpreter that raised the event.
344349
345-
The *userData* pointer is passed into the hook function. Since hook
346-
functions may be called from different runtimes, this pointer should not
347-
refer directly to Python state.
348-
349-
See :pep:`578` for a detailed description of auditing. Functions in the
350-
runtime and standard library that raise events include the details in each
351-
function's documentation and listed in the :ref:`audit events table
352-
<audit-events>`.
350+
See :pep:`578` for a detailed description of auditing. Functions in the
351+
runtime and standard library that raise events are listed in the
352+
:ref:`audit events table <audit-events>`.
353+
Details are in each function's documentation.
353354
354355
.. audit-event:: sys.addaudithook "" c.PySys_AddAuditHook
355356

Doc/library/audit_events.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Audit events table
77

88
This table contains all events raised by :func:`sys.audit` or
99
:c:func:`PySys_Audit` calls throughout the CPython runtime and the
10-
standard library.
10+
standard library. These calls were added in 3.8.0 or later.
1111

1212
See :func:`sys.addaudithook` and :c:func:`PySys_AddAuditHook` for
1313
information on handling these events.

Doc/library/sys.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ always available.
2525

2626
.. function:: addaudithook(hook)
2727

28-
Adds the callable *hook* to the collection of active auditing hooks for the
28+
Append the callable *hook* to the list of active auditing hooks for the
2929
current interpreter.
3030

3131
When an auditing event is raised through the :func:`sys.audit` function, each
@@ -35,7 +35,7 @@ always available.
3535

3636
.. audit-event:: sys.addaudithook "" sys.addaudithook
3737

38-
Raises a auditing event ``sys.addaudithook`` with no arguments. If any
38+
Raise an auditing event ``sys.addaudithook`` with no arguments. If any
3939
existing hooks raise an exception derived from :class:`Exception`, the
4040
new hook will not be added and the exception suppressed. As a result,
4141
callers cannot assume that their hook has been added unless they control
@@ -74,7 +74,7 @@ always available.
7474

7575
.. index:: single: auditing
7676

77-
Raises an auditing event with any active hooks. The event name is a string
77+
Raise an auditing event with any active hooks. The event name is a string
7878
identifying the event and its associated schema, which is the number and
7979
types of arguments. The schema for a given event is considered public and
8080
stable API and should not be modified between releases.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve documentation for audit events table and functions.

0 commit comments

Comments
 (0)