Skip to content

Commit 44f91c3

Browse files
authored
bpo-37390: Add audit event table to documentations (GH-14406)
Also updates some (unreleased) event names to be consistent with the others.
1 parent 21cfae1 commit 44f91c3

34 files changed

+266
-113
lines changed

Doc/c-api/code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bound into a function.
4545
The first parameter (*argcount*) now represents the total number of positional arguments,
4646
including positional-only.
4747
48-
.. audit-event:: code.__new__ "code filename name argcount posonlyargcount kwonlyargcount nlocals stacksize flags"
48+
.. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags c.PyCode_New
4949
5050
.. c:function:: PyCodeObject* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
5151

Doc/c-api/sys.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ accessible to C code. They all work with the current interpreter thread's
291291
292292
.. c:function:: int PySys_Audit(const char *event, const char *format, ...)
293293
294-
.. index:: single: audit events
295-
296294
Raises an auditing event with any active hooks. Returns zero for success
297295
and non-zero with an exception set on failure.
298296
@@ -311,8 +309,6 @@ accessible to C code. They all work with the current interpreter thread's
311309
312310
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
313311
314-
.. index:: single: audit events
315-
316312
Adds to the collection of active auditing hooks. Returns zero for success
317313
and non-zero on failure. If the runtime has been initialized, also sets an
318314
error on failure. Hooks added through this API are called for all

Doc/library/array.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The module defines the following type:
8383
to add initial items to the array. Otherwise, the iterable initializer is
8484
passed to the :meth:`extend` method.
8585

86-
.. audit-event:: array.__new__ "typecode initializer"
86+
.. audit-event:: array.__new__ typecode,initializer array.array
8787

8888
.. data:: typecodes
8989

Doc/library/audit_events.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. _audit-events:
2+
3+
.. index:: single: audit events
4+
5+
Audit events table
6+
==================
7+
8+
This table contains all events raised by :func:`sys.audit` or
9+
:c:func:`PySys_Audit` calls throughout the CPython runtime and the
10+
standard library.
11+
12+
See :func:`sys.addaudithook` and :c:func:`PySys_AddAuditHook` for
13+
information on handling these events.
14+
15+
.. impl-detail::
16+
17+
This table is generated from the CPython documentation, and may not
18+
represent events raised by other implementations. See your runtime
19+
specific documentation for actual events raised.
20+
21+
.. audit-event-table::

Doc/library/ctypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,13 +1509,13 @@ object is available:
15091509
:c:type:`int`, which is of course not always the truth, so you have to assign
15101510
the correct :attr:`restype` attribute to use these functions.
15111511

1512-
.. audit-event:: ctypes.dlopen name
1512+
.. audit-event:: ctypes.dlopen name ctypes.LibraryLoader
15131513

15141514
Loading a library through any of these objects raises an
15151515
:ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument
15161516
``name``, the name used to load the library.
15171517

1518-
.. audit-event:: ctypes.dlsym "library name"
1518+
.. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader
15191519

15201520
Accessing a function on a loaded library raises an auditing event
15211521
``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name``
@@ -2043,7 +2043,7 @@ Data types
20432043
This method returns a ctypes type instance using the memory specified by
20442044
*address* which must be an integer.
20452045

2046-
.. audit-event:: ctypes.cdata address
2046+
.. audit-event:: ctypes.cdata address ctypes._CData.from_address
20472047

20482048
This method, and others that indirectly call this method, raises an
20492049
:ref:`auditing event <auditing>` ``ctypes.cdata`` with argument

Doc/library/debug.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ Debugging and Profiling
55
These libraries help you with Python development: the debugger enables you to
66
step through code, analyze stack frames and set breakpoints etc., and the
77
profilers run code and give you a detailed breakdown of execution times,
8-
allowing you to identify bottlenecks in your programs.
8+
allowing you to identify bottlenecks in your programs. Auditing events
9+
provide visibility into runtime behaviors that would otherwise require
10+
intrusive debugging or patching.
911

1012
.. toctree::
1113

14+
audit_events.rst
1215
bdb.rst
1316
faulthandler.rst
1417
pdb.rst

Doc/library/ensurepip.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Module API
119119
*verbosity* controls the level of output to :data:`sys.stdout` from the
120120
bootstrapping operation.
121121

122-
.. audit-event:: ensurepip.bootstrap root
122+
.. audit-event:: ensurepip.bootstrap root ensurepip.bootstrap
123123

124124
.. note::
125125

Doc/library/ftplib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version.
190190
*source_address* is a 2-tuple ``(host, port)`` for the socket to bind to as
191191
its source address before connecting.
192192

193-
.. audit-event:: ftplib.FTP.connect "self host port"
193+
.. audit-event:: ftplib.connect self,host,port ftplib.FTP.connect
194194

195195
.. versionchanged:: 3.3
196196
*source_address* parameter was added.
@@ -225,7 +225,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version.
225225

226226
Send a simple command string to the server and return the response string.
227227

228-
.. audit-event:: ftplib.FTP.sendcmd "self cmd"
228+
.. audit-event:: ftplib.sendcmd self,cmd ftplib.FTP.sendcmd
229229

230230

231231
.. method:: FTP.voidcmd(cmd)
@@ -234,7 +234,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version.
234234
nothing if a response code corresponding to success (codes in the range
235235
200--299) is received. Raise :exc:`error_reply` otherwise.
236236

237-
.. audit-event:: ftplib.FTP.sendcmd "self cmd"
237+
.. audit-event:: ftplib.sendcmd self,cmd ftplib.FTP.voidcmd
238238

239239

240240
.. method:: FTP.retrbinary(cmd, callback, blocksize=8192, rest=None)

Doc/library/functions.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ are always available. They are listed here in alphabetical order.
128128
:func:`breakpoint` will automatically call that, allowing you to drop into
129129
the debugger of choice.
130130

131-
.. audit-event:: builtins.breakpoint "sys.breakpointhook"
131+
.. audit-event:: builtins.breakpoint breakpointhook breakpoint
132132

133133
.. versionadded:: 3.7
134134

@@ -277,7 +277,7 @@ are always available. They are listed here in alphabetical order.
277277
If you want to parse Python code into its AST representation, see
278278
:func:`ast.parse`.
279279

280-
.. audit-event:: compile "source filename"
280+
.. audit-event:: compile source,filename compile
281281

282282
Raises an :ref:`auditing event <auditing>` ``compile`` with arguments
283283
``source`` and ``filename``. This event may also be raised by implicit
@@ -490,7 +490,7 @@ are always available. They are listed here in alphabetical order.
490490
See :func:`ast.literal_eval` for a function that can safely evaluate strings
491491
with expressions containing only literals.
492492

493-
.. audit-event:: exec code_object
493+
.. audit-event:: exec code_object eval
494494

495495
Raises an :ref:`auditing event <auditing>` ``exec`` with the code object
496496
as the argument. Code compilation events may also be raised.
@@ -525,7 +525,7 @@ are always available. They are listed here in alphabetical order.
525525
builtins are available to the executed code by inserting your own
526526
``__builtins__`` dictionary into *globals* before passing it to :func:`exec`.
527527

528-
.. audit-event:: exec code_object
528+
.. audit-event:: exec code_object exec
529529

530530
Raises an :ref:`auditing event <auditing>` ``exec`` with the code object
531531
as the argument. Code compilation events may also be raised.
@@ -779,12 +779,12 @@ are always available. They are listed here in alphabetical order.
779779
If the :mod:`readline` module was loaded, then :func:`input` will use it
780780
to provide elaborate line editing and history features.
781781

782-
.. audit-event:: builtins.input prompt
782+
.. audit-event:: builtins.input prompt input
783783

784784
Raises an :ref:`auditing event <auditing>` ``builtins.input`` with
785785
argument ``prompt`` before reading input
786786

787-
.. audit-event:: builtins.input/result result
787+
.. audit-event:: builtins.input/result result input
788788

789789
Raises an auditing event ``builtins.input/result`` with the result after
790790
successfully reading input.
@@ -1222,7 +1222,7 @@ are always available. They are listed here in alphabetical order.
12221222
(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:`tempfile`,
12231223
and :mod:`shutil`.
12241224

1225-
.. audit-event:: open "file mode flags"
1225+
.. audit-event:: open file,mode,flags open
12261226

12271227
The ``mode`` and ``flags`` arguments may have been modified or inferred from
12281228
the original call.

Doc/library/glob.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ For example, ``'[?]'`` matches the character ``'?'``.
5252
more directories and subdirectories. If the pattern is followed by an
5353
``os.sep``, only directories and subdirectories match.
5454

55-
.. audit-event:: glob.glob "pathname recursive"
55+
.. audit-event:: glob.glob pathname,recursive glob.glob
5656

5757
.. note::
5858
Using the "``**``" pattern in large directory trees may consume
@@ -67,7 +67,7 @@ For example, ``'[?]'`` matches the character ``'?'``.
6767
Return an :term:`iterator` which yields the same values as :func:`glob`
6868
without actually storing them all simultaneously.
6969

70-
.. audit-event:: glob.glob "pathname recursive"
70+
.. audit-event:: glob.glob pathname,recursive glob.iglob
7171

7272

7373
.. function:: escape(pathname)

Doc/library/imaplib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ An :class:`IMAP4` instance has the following methods:
361361
:meth:`IMAP4.send`, and :meth:`IMAP4.shutdown` methods. You may override
362362
this method.
363363

364-
.. audit-event:: imaplib.IMAP4.open "self host port"
364+
.. audit-event:: imaplib.open self,host,port imaplib.IMAP4.open
365365

366366

367367
.. method:: IMAP4.partial(message_num, message_part, start, length)
@@ -432,7 +432,7 @@ An :class:`IMAP4` instance has the following methods:
432432

433433
Sends ``data`` to the remote server. You may override this method.
434434

435-
.. audit-event:: imaplib.IMAP4.send "self data"
435+
.. audit-event:: imaplib.send self,data imaplib.IMAP4.send
436436

437437

438438
.. method:: IMAP4.setacl(mailbox, who, what)

Doc/library/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ High-level Module Interface
120120

121121
This is an alias for the builtin :func:`open` function.
122122

123-
.. audit-event:: open "path mode flags"
123+
.. audit-event:: open path,mode,flags io.open
124124

125125
This function raises an :ref:`auditing event <auditing>` ``open`` with
126126
arguments ``path``, ``mode`` and ``flags``. The ``mode`` and ``flags``

Doc/library/mmap.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
6767
will be relative to the offset from the beginning of the file. *offset*
6868
defaults to 0. *offset* must be a multiple of the :const:`ALLOCATIONGRANULARITY`.
6969

70-
.. audit-event:: mmap.__new__ "fileno length access offset"
70+
.. audit-event:: mmap.__new__ fileno,length,access,offset mmap.mmap
7171

7272
.. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, access=ACCESS_DEFAULT[, offset])
7373
:noindex:
@@ -156,7 +156,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
156156

157157
mm.close()
158158

159-
.. audit-event:: mmap.__new__ "fileno length access offset"
159+
.. audit-event:: mmap.__new__ fileno,length,access,offset mmap.mmap
160160

161161
Memory-mapped file objects support the following methods:
162162

Doc/library/nntplib.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ The module itself defines the following classes:
7979
('211 1755 1 1755 gmane.comp.python.committers', 1755, 1, 1755, 'gmane.comp.python.committers')
8080
>>>
8181

82-
.. audit-event:: nntplib.NNTP "self host port"
82+
.. audit-event:: nntplib.connect self,host,port nntplib.NNTP
8383

84-
All commands will raise an :ref:`auditing event <auditing>`
85-
``nntplib.NNTP.putline`` with arguments ``self`` and ``line``,
86-
where ``line`` is the bytes about to be sent to the remote host.
84+
.. audit-event:: nntplib.putline self,line nntplib.NNTP
85+
86+
All commands will raise an :ref:`auditing event <auditing>`
87+
``nntplib.putline`` with arguments ``self`` and ``line``,
88+
where ``line`` is the bytes about to be sent to the remote host.
8789

8890
.. versionchanged:: 3.2
8991
*usenetrc* is now ``False`` by default.
@@ -105,11 +107,13 @@ The module itself defines the following classes:
105107
STARTTLS as described below. However, some servers only support the
106108
former.
107109

108-
.. audit-event:: nntplib.NNTP "self host port"
110+
.. audit-event:: nntplib.connect self,host,port nntplib.NNTP_SSL
111+
112+
.. audit-event:: nntplib.putline self,line nntplib.NNTP_SSL
109113

110-
All commands will raise an :ref:`auditing event <auditing>`
111-
``nntplib.NNTP.putline`` with arguments ``self`` and ``line``,
112-
where ``line`` is the bytes about to be sent to the remote host.
114+
All commands will raise an :ref:`auditing event <auditing>`
115+
``nntplib.putline`` with arguments ``self`` and ``line``,
116+
where ``line`` is the bytes about to be sent to the remote host.
113117

114118
.. versionadded:: 3.2
115119

Doc/library/os.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ as internal buffering of data.
851851
most *length* bytes in size. As of Python 3.3, this is equivalent to
852852
``os.truncate(fd, length)``.
853853

854-
.. audit-event:: os.truncate "fd length"
854+
.. audit-event:: os.truncate fd,length os.ftruncate
855855

856856
.. availability:: Unix, Windows.
857857

@@ -938,7 +938,7 @@ as internal buffering of data.
938938
This function can support :ref:`paths relative to directory descriptors
939939
<dir_fd>` with the *dir_fd* parameter.
940940

941-
.. audit-event:: open "path mode flags"
941+
.. audit-event:: open path,mode,flags os.open
942942

943943
.. versionchanged:: 3.4
944944
The new file descriptor is now non-inheritable.
@@ -1806,7 +1806,7 @@ features:
18061806
This function can also support :ref:`specifying a file descriptor
18071807
<path_fd>`; the file descriptor must refer to a directory.
18081808

1809-
.. audit-event:: os.listdir path
1809+
.. audit-event:: os.listdir path os.listdir
18101810

18111811
.. note::
18121812
To encode ``str`` filenames to ``bytes``, use :func:`~os.fsencode`.
@@ -2185,7 +2185,7 @@ features:
21852185
This function can also support :ref:`specifying a file descriptor
21862186
<path_fd>`; the file descriptor must refer to a directory.
21872187

2188-
.. audit-event:: os.scandir path
2188+
.. audit-event:: os.scandir path os.scandir
21892189

21902190
The :func:`scandir` iterator supports the :term:`context manager` protocol
21912191
and has the following method:
@@ -2793,7 +2793,7 @@ features:
27932793

27942794
This function can support :ref:`specifying a file descriptor <path_fd>`.
27952795

2796-
.. audit-event:: os.truncate "path length"
2796+
.. audit-event:: os.truncate path,length os.truncate
27972797

27982798
.. availability:: Unix, Windows.
27992799

@@ -3799,7 +3799,7 @@ written in Python, such as a mail server's external command delivery program.
37993799
to using this function. See the :ref:`subprocess-replacements` section in
38003800
the :mod:`subprocess` documentation for some helpful recipes.
38013801

3802-
.. audit-event:: os.system command
3802+
.. audit-event:: os.system command os.system
38033803

38043804
.. availability:: Unix, Windows.
38053805

Doc/library/pdb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ access further features, you have to do this yourself:
181181

182182
import pdb; pdb.Pdb(skip=['django.*']).set_trace()
183183

184-
.. audit-event:: pdb.Pdb
184+
.. audit-event:: pdb.Pdb "" pdb.Pdb
185185

186186
.. versionadded:: 3.1
187187
The *skip* argument.

Doc/library/pickle.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ The :mod:`pickle` module exports three classes, :class:`Pickler`,
437437
how they can be loaded, potentially reducing security risks. Refer to
438438
:ref:`pickle-restrict` for details.
439439

440-
.. audit-event:: pickle.find_class "module name"
440+
.. audit-event:: pickle.find_class module,name pickle.Unpickler.find_class
441441

442442
.. class:: PickleBuffer(buffer)
443443

0 commit comments

Comments
 (0)