Skip to content

Commit 6768860

Browse files
[3.12] gh-101100: Clean up Doc/c-api/exceptions.rst and Doc/c-api/sys.rst (GH-114825) (GH-115308)
(cherry picked from commit e1552fd) Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
1 parent 18f5264 commit 6768860

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

Doc/c-api/exceptions.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ an error value).
383383
.. c:function:: int PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level, const char *format, ...)
384384
385385
Function similar to :c:func:`PyErr_WarnFormat`, but *category* is
386-
:exc:`ResourceWarning` and it passes *source* to :func:`warnings.WarningMessage`.
386+
:exc:`ResourceWarning` and it passes *source* to :class:`!warnings.WarningMessage`.
387387
388388
.. versionadded:: 3.6
389389
@@ -719,7 +719,7 @@ Exception Classes
719719
This creates a class object derived from :exc:`Exception` (accessible in C as
720720
:c:data:`PyExc_Exception`).
721721
722-
The :attr:`__module__` attribute of the new class is set to the first part (up
722+
The :attr:`!__module__` attribute of the new class is set to the first part (up
723723
to the last dot) of the *name* argument, and the class name is set to the last
724724
part (after the last dot). The *base* argument can be used to specify alternate
725725
base classes; it can either be only one class or a tuple of classes. The *dict*
@@ -891,8 +891,8 @@ because the :ref:`call protocol <call>` takes care of recursion handling.
891891
892892
Marks a point where a recursive C-level call is about to be performed.
893893
894-
If :c:macro:`USE_STACKCHECK` is defined, this function checks if the OS
895-
stack overflowed using :c:func:`PyOS_CheckStack`. In this is the case, it
894+
If :c:macro:`!USE_STACKCHECK` is defined, this function checks if the OS
895+
stack overflowed using :c:func:`PyOS_CheckStack`. If this is the case, it
896896
sets a :exc:`MemoryError` and returns a nonzero value.
897897
898898
The function then checks if the recursion limit is reached. If this is the
@@ -1145,11 +1145,11 @@ These are compatibility aliases to :c:data:`PyExc_OSError`:
11451145
+-------------------------------------+----------+
11461146
| C Name | Notes |
11471147
+=====================================+==========+
1148-
| :c:data:`PyExc_EnvironmentError` | |
1148+
| :c:data:`!PyExc_EnvironmentError` | |
11491149
+-------------------------------------+----------+
1150-
| :c:data:`PyExc_IOError` | |
1150+
| :c:data:`!PyExc_IOError` | |
11511151
+-------------------------------------+----------+
1152-
| :c:data:`PyExc_WindowsError` | [2]_ |
1152+
| :c:data:`!PyExc_WindowsError` | [2]_ |
11531153
+-------------------------------------+----------+
11541154
11551155
.. versionchanged:: 3.3

Doc/c-api/sys.rst

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Operating System Utilities
66
==========================
77

8+
89
.. c:function:: PyObject* PyOS_FSPath(PyObject *path)
910
1011
Return the file system representation for *path*. If the object is a
@@ -97,27 +98,30 @@ Operating System Utilities
9798
9899
.. c:function:: int PyOS_CheckStack()
99100
101+
.. index:: single: USE_STACKCHECK (C macro)
102+
100103
Return true when the interpreter runs out of stack space. This is a reliable
101-
check, but is only available when :c:macro:`USE_STACKCHECK` is defined (currently
104+
check, but is only available when :c:macro:`!USE_STACKCHECK` is defined (currently
102105
on certain versions of Windows using the Microsoft Visual C++ compiler).
103-
:c:macro:`USE_STACKCHECK` will be defined automatically; you should never
106+
:c:macro:`!USE_STACKCHECK` will be defined automatically; you should never
104107
change the definition in your own code.
105108
106109
110+
.. c:type:: void (*PyOS_sighandler_t)(int)
111+
112+
107113
.. c:function:: PyOS_sighandler_t PyOS_getsig(int i)
108114
109115
Return the current signal handler for signal *i*. This is a thin wrapper around
110116
either :c:func:`!sigaction` or :c:func:`!signal`. Do not call those functions
111-
directly! :c:type:`PyOS_sighandler_t` is a typedef alias for :c:expr:`void
112-
(\*)(int)`.
117+
directly!
113118
114119
115120
.. c:function:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
116121
117122
Set the signal handler for signal *i* to be *h*; return the old signal handler.
118123
This is a thin wrapper around either :c:func:`!sigaction` or :c:func:`!signal`. Do
119-
not call those functions directly! :c:type:`PyOS_sighandler_t` is a typedef
120-
alias for :c:expr:`void (\*)(int)`.
124+
not call those functions directly!
121125
122126
.. c:function:: wchar_t* Py_DecodeLocale(const char* arg, size_t *size)
123127
@@ -380,10 +384,8 @@ accessible to C code. They all work with the current interpreter thread's
380384
silently abort the operation by raising an error subclassed from
381385
:class:`Exception` (other errors will not be silenced).
382386
383-
The hook function is of type :c:expr:`int (*)(const char *event, PyObject
384-
*args, void *userData)`, where *args* is guaranteed to be a
385-
:c:type:`PyTupleObject`. The hook function is always called with the GIL
386-
held by the Python interpreter that raised the event.
387+
The hook function is always called with the GIL held by the Python
388+
interpreter that raised the event.
387389
388390
See :pep:`578` for a detailed description of auditing. Functions in the
389391
runtime and standard library that raise events are listed in the
@@ -392,12 +394,20 @@ accessible to C code. They all work with the current interpreter thread's
392394
393395
.. audit-event:: sys.addaudithook "" c.PySys_AddAuditHook
394396
395-
If the interpreter is initialized, this function raises a auditing event
397+
If the interpreter is initialized, this function raises an auditing event
396398
``sys.addaudithook`` with no arguments. If any existing hooks raise an
397399
exception derived from :class:`Exception`, the new hook will not be
398400
added and the exception is cleared. As a result, callers cannot assume
399401
that their hook has been added unless they control all existing hooks.
400402
403+
.. c:namespace:: NULL
404+
.. c:type:: int (*Py_AuditHookFunction) (const char *event, PyObject *args, void *userData)
405+
406+
The type of the hook function.
407+
*event* is the C string event argument passed to :c:func:`PySys_Audit`.
408+
*args* is guaranteed to be a :c:type:`PyTupleObject`.
409+
*userData* is the argument passed to PySys_AddAuditHook().
410+
401411
.. versionadded:: 3.8
402412
403413

Doc/tools/.nitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Doc/c-api/arg.rst
66
Doc/c-api/descriptor.rst
7-
Doc/c-api/exceptions.rst
87
Doc/c-api/float.rst
98
Doc/c-api/gcsupport.rst
109
Doc/c-api/init.rst
@@ -13,7 +12,6 @@ Doc/c-api/intro.rst
1312
Doc/c-api/module.rst
1413
Doc/c-api/object.rst
1514
Doc/c-api/stable.rst
16-
Doc/c-api/sys.rst
1715
Doc/c-api/type.rst
1816
Doc/c-api/typeobj.rst
1917
Doc/extending/extending.rst

0 commit comments

Comments
 (0)