Skip to content

Commit 9a6bdfa

Browse files
committed
Merge branch 'main' into superfix
* main: (73 commits) Thoroughly refactor the cases generator (python#107151) Docs: Add missing markup to Argument Clinic docs (python#106876) pythongh-107162: Document errcode.h usage in its comment (python#107177) pythongh-106320: Remove private _PyDict C API (python#107145) Fix PyVectorcall_Function doc versionadded (python#107140) Docs: Remove duplicate word in Argument Clinic howto heading (python#107169) pythongh-107017: Change Chapter Strings to Texts in the Introduction chapter. (python#107104) pythongh-106320: Remove private _PyObject C API (python#107159) Docs: fix typo in os.pwrite docstring (python#107087) pythongh-105291: Add link to migration guide for distutils (python#107130) pythongh-106948: Docs: Disable links for C standard library functions, OS utility functions and system calls (python#107062) pythongh-106320: Remove _PyBytes_Join() C API (python#107144) pythongh-106320: Remove private _PyObject C API (python#107147) pythongh-106320: Remove _PyTuple_MaybeUntrack() C API (python#107143) pythongh-106320: Remove _PyIsSelectable_fd() C API (python#107142) Remove superflous whitespaces in `layout.html`. (pythonGH-107067) pythongh-107122: Update what's news for dbm.*dbm.clear() method (pythongh-107135) pythongh-107122: Add clear method to dbm.ndbm module (pythongh-107126) pythongh-62519: Make pgettext search plurals when translation is not found (python#107118) pythongh-107122: Add clear method to dbm.gdbm.module (pythongh-107127) ...
2 parents b9fab74 + 032f480 commit 9a6bdfa

File tree

214 files changed

+3637
-2478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+3637
-2478
lines changed

.github/workflows/reusable-docs.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,28 @@ jobs:
2828
cache-dependency-path: 'Doc/requirements.txt'
2929
- name: 'Install build dependencies'
3030
run: make -C Doc/ venv
31-
- name: 'Build HTML documentation'
32-
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
3331

34-
# Add pull request annotations for Sphinx nitpicks (missing references)
32+
# To annotate PRs with Sphinx nitpicks (missing references)
3533
- name: 'Get list of changed files'
3634
if: github.event_name == 'pull_request'
3735
id: changed_files
3836
uses: Ana06/[email protected]
3937
with:
4038
filter: "Doc/**"
4139
format: csv # works for paths with spaces
42-
- name: 'Build changed files in nit-picky mode'
43-
if: github.event_name == 'pull_request'
40+
- name: 'Build HTML documentation'
4441
continue-on-error: true
4542
run: |
4643
set -Eeuo pipefail
47-
# Mark files the pull request modified
48-
python Doc/tools/touch-clean-files.py --clean '${{ steps.changed_files.outputs.added_modified }}'
49-
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
50-
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
51-
python Doc/tools/warnings-to-gh-actions.py
52-
53-
# Ensure some files always pass Sphinx nit-picky mode (no missing references)
54-
- name: 'Build known-good files in nit-picky mode'
44+
# Build docs with the '-n' (nit-picky) option; write warnings to file
45+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going -w sphinx-warnings.txt" html
46+
- name: 'Check warnings'
47+
if: github.event_name == 'pull_request'
5548
run: |
56-
# Mark files that must pass nit-picky
57-
python Doc/tools/touch-clean-files.py
58-
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
59-
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
49+
python Doc/tools/check-warnings.py \
50+
--check-and-annotate '${{ steps.changed_files.outputs.added_modified }}' \
51+
--fail-if-regression \
52+
--fail-if-improved
6053
6154
# This build doesn't use problem matchers or check annotations
6255
build_doc_oldest_supported_sphinx:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
types_or: [c, python, rst]
1111

1212
- repo: https://github.com/sphinx-contrib/sphinx-lint
13-
rev: v0.6.7
13+
rev: v0.6.8
1414
hooks:
1515
- id: sphinx-lint
1616
args: [--enable=default-role]

Doc/c-api/arg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ Building values
555555
Same as ``s#``.
556556
557557
``u`` (:class:`str`) [const wchar_t \*]
558-
Convert a null-terminated :c:expr:`wchar_t` buffer of Unicode (UTF-16 or UCS-4)
558+
Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or UCS-4)
559559
data to a Python Unicode object. If the Unicode buffer pointer is ``NULL``,
560560
``None`` is returned.
561561

Doc/c-api/buffer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ object via :c:func:`PyObject_GetBuffer`. Since the complexity of the logical
225225
structure of the memory can vary drastically, the consumer uses the *flags*
226226
argument to specify the exact buffer type it can handle.
227227

228-
All :c:data:`Py_buffer` fields are unambiguously defined by the request
228+
All :c:type:`Py_buffer` fields are unambiguously defined by the request
229229
type.
230230

231231
request-independent fields
@@ -464,7 +464,7 @@ Buffer-related functions
464464
465465
.. c:function:: Py_ssize_t PyBuffer_SizeFromFormat(const char *format)
466466
467-
Return the implied :c:data:`~Py_buffer.itemsize` from :c:data:`~Py_buffer.format`.
467+
Return the implied :c:member:`~Py_buffer.itemsize` from :c:member:`~Py_buffer.format`.
468468
On error, raise an exception and return -1.
469469
470470
.. versionadded:: 3.9

Doc/c-api/call.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Vectorcall Support API
152152
This is mostly useful to check whether or not *op* supports vectorcall,
153153
which can be done by checking ``PyVectorcall_Function(op) != NULL``.
154154
155-
.. versionadded:: 3.8
155+
.. versionadded:: 3.9
156156
157157
.. c:function:: PyObject* PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict)
158158

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ For convenience, some of these functions will always return a
163163
This is a convenience function to raise an exception when a C library function
164164
has returned an error and set the C variable :c:data:`errno`. It constructs a
165165
tuple object whose first item is the integer :c:data:`errno` value and whose
166-
second item is the corresponding error message (gotten from :c:func:`strerror`),
166+
second item is the corresponding error message (gotten from :c:func:`!strerror`),
167167
and then calls ``PyErr_SetObject(type, object)``. On Unix, when the
168168
:c:data:`errno` value is :c:macro:`EINTR`, indicating an interrupted system call,
169169
this calls :c:func:`PyErr_CheckSignals`, and if that set the error indicator,

Doc/c-api/iterator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Iterator Objects
66
----------------
77

88
Python provides two general-purpose iterator objects. The first, a sequence
9-
iterator, works with an arbitrary sequence supporting the :meth:`__getitem__`
9+
iterator, works with an arbitrary sequence supporting the :meth:`~object.__getitem__`
1010
method. The second works with a callable object and a sentinel value, calling
1111
the callable for each item in the sequence, and ending the iteration when the
1212
sentinel value is returned.

Doc/c-api/mapping.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
1313
1414
Return ``1`` if the object provides the mapping protocol or supports slicing,
1515
and ``0`` otherwise. Note that it returns ``1`` for Python classes with
16-
a :meth:`__getitem__` method, since in general it is impossible to
16+
a :meth:`~object.__getitem__` method, since in general it is impossible to
1717
determine what type of keys the class supports. This function always succeeds.
1818
1919
@@ -90,7 +90,7 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
9090
This is equivalent to the Python expression ``key in o``.
9191
This function always succeeds.
9292
93-
Note that exceptions which occur while calling the :meth:`__getitem__`
93+
Note that exceptions which occur while calling the :meth:`~object.__getitem__`
9494
method will get suppressed.
9595
To get error reporting use :c:func:`PyObject_GetItem()` instead.
9696
@@ -101,7 +101,7 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
101101
This is equivalent to the Python expression ``key in o``.
102102
This function always succeeds.
103103
104-
Note that exceptions which occur while calling the :meth:`__getitem__`
104+
Note that exceptions which occur while calling the :meth:`~object.__getitem__`
105105
method and creating a temporary string object will get suppressed.
106106
To get error reporting use :c:func:`PyMapping_GetItemString()` instead.
107107

Doc/c-api/memory.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ that the treatment of negative indices differs from a Python slice):
581581
default).
582582
583583
A serial number, incremented by 1 on each call to a malloc-like or
584-
realloc-like function. Big-endian ``size_t``. If "bad memory" is detected
584+
realloc-like function. Big-endian :c:type:`size_t`. If "bad memory" is detected
585585
later, the serial number gives an excellent way to set a breakpoint on the
586586
next run, to capture the instant at which this block was passed out. The
587587
static function bumpserialno() in obmalloc.c is the only place the serial

Doc/c-api/method.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Instance Method Objects
77

88
.. index:: pair: object; instancemethod
99

10-
An instance method is a wrapper for a :c:data:`PyCFunction` and the new way
11-
to bind a :c:data:`PyCFunction` to a class object. It replaces the former call
10+
An instance method is a wrapper for a :c:type:`PyCFunction` and the new way
11+
to bind a :c:type:`PyCFunction` to a class object. It replaces the former call
1212
``PyMethod_New(func, NULL, class)``.
1313

1414

Doc/c-api/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ or request "multi-phase initialization" by returning the definition struct itsel
145145
146146
.. c:member:: PyModuleDef_Base m_base
147147
148-
Always initialize this member to :c:data:`PyModuleDef_HEAD_INIT`.
148+
Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`.
149149
150150
.. c:member:: const char *m_name
151151

Doc/c-api/refcounting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ of Python objects.
101101
.. warning::
102102
103103
The deallocation function can cause arbitrary Python code to be invoked (e.g.
104-
when a class instance with a :meth:`__del__` method is deallocated). While
104+
when a class instance with a :meth:`~object.__del__` method is deallocated). While
105105
exceptions in such code are not propagated, the executed code has free access to
106106
all Python global variables. This means that any object that is reachable from
107107
a global variable should be in a consistent state before :c:func:`Py_DECREF` is

Doc/c-api/sequence.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Sequence Protocol
99
.. c:function:: int PySequence_Check(PyObject *o)
1010
1111
Return ``1`` if the object provides the sequence protocol, and ``0`` otherwise.
12-
Note that it returns ``1`` for Python classes with a :meth:`__getitem__`
12+
Note that it returns ``1`` for Python classes with a :meth:`~object.__getitem__`
1313
method, unless they are :class:`dict` subclasses, since in general it
1414
is impossible to determine what type of keys the class supports. This
1515
function always succeeds.

Doc/c-api/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ Operating System Utilities
106106
.. c:function:: PyOS_sighandler_t PyOS_getsig(int i)
107107
108108
Return the current signal handler for signal *i*. This is a thin wrapper around
109-
either :c:func:`sigaction` or :c:func:`signal`. Do not call those functions
109+
either :c:func:`!sigaction` or :c:func:`!signal`. Do not call those functions
110110
directly! :c:type:`PyOS_sighandler_t` is a typedef alias for :c:expr:`void
111111
(\*)(int)`.
112112
113113
114114
.. c:function:: PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
115115
116116
Set the signal handler for signal *i* to be *h*; return the old signal handler.
117-
This is a thin wrapper around either :c:func:`sigaction` or :c:func:`signal`. Do
117+
This is a thin wrapper around either :c:func:`!sigaction` or :c:func:`!signal`. Do
118118
not call those functions directly! :c:type:`PyOS_sighandler_t` is a typedef
119119
alias for :c:expr:`void (\*)(int)`.
120120

Doc/c-api/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Type Objects
215215
``Py_TYPE(self)`` may be a *subclass* of the intended class, and subclasses
216216
are not necessarily defined in the same module as their superclass.
217217
See :c:type:`PyCMethod` to get the class that defines the method.
218-
See :c:func:`PyType_GetModuleByDef` for cases when ``PyCMethod`` cannot
218+
See :c:func:`PyType_GetModuleByDef` for cases when :c:type:`!PyCMethod` cannot
219219
be used.
220220
221221
.. versionadded:: 3.9

Doc/c-api/typeobj.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,8 +2255,8 @@ Number Object Structures
22552255

22562256
.. note::
22572257

2258-
The :c:data:`nb_reserved` field should always be ``NULL``. It
2259-
was previously called :c:data:`nb_long`, and was renamed in
2258+
The :c:member:`~PyNumberMethods.nb_reserved` field should always be ``NULL``. It
2259+
was previously called :c:member:`!nb_long`, and was renamed in
22602260
Python 3.0.1.
22612261

22622262
.. c:member:: binaryfunc PyNumberMethods.nb_add

Doc/c-api/unicode.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Python:
4444

4545
.. c:type:: Py_UNICODE
4646
47-
This is a typedef of :c:expr:`wchar_t`, which is a 16-bit type or 32-bit type
47+
This is a typedef of :c:type:`wchar_t`, which is a 16-bit type or 32-bit type
4848
depending on the platform.
4949

5050
.. versionchanged:: 3.3
@@ -437,11 +437,11 @@ APIs:
437437
+----------+-----------------------------------------------------+
438438
| ``ll`` | :c:expr:`long long` or :c:expr:`unsigned long long` |
439439
+----------+-----------------------------------------------------+
440-
| ``j`` | :c:expr:`intmax_t` or :c:expr:`uintmax_t` |
440+
| ``j`` | :c:type:`intmax_t` or :c:type:`uintmax_t` |
441441
+----------+-----------------------------------------------------+
442-
| ``z`` | :c:expr:`size_t` or :c:expr:`ssize_t` |
442+
| ``z`` | :c:type:`size_t` or :c:type:`ssize_t` |
443443
+----------+-----------------------------------------------------+
444-
| ``t`` | :c:expr:`ptrdiff_t` |
444+
| ``t`` | :c:type:`ptrdiff_t` |
445445
+----------+-----------------------------------------------------+
446446
447447
The length modifier ``l`` for following conversions ``s`` or ``V`` specify
@@ -520,7 +520,7 @@ APIs:
520520
521521
.. note::
522522
The width formatter unit is number of characters rather than bytes.
523-
The precision formatter unit is number of bytes or :c:expr:`wchar_t`
523+
The precision formatter unit is number of bytes or :c:type:`wchar_t`
524524
items (if the length modifier ``l`` is used) for ``"%s"`` and
525525
``"%V"`` (if the ``PyObject*`` argument is ``NULL``), and a number of
526526
characters for ``"%A"``, ``"%U"``, ``"%S"``, ``"%R"`` and ``"%V"``
@@ -839,21 +839,21 @@ conversion function:
839839
wchar_t Support
840840
"""""""""""""""
841841
842-
:c:expr:`wchar_t` support for platforms which support it:
842+
:c:type:`wchar_t` support for platforms which support it:
843843
844844
.. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
845845
846-
Create a Unicode object from the :c:expr:`wchar_t` buffer *w* of the given *size*.
846+
Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*.
847847
Passing ``-1`` as the *size* indicates that the function must itself compute the length,
848848
using wcslen.
849849
Return ``NULL`` on failure.
850850
851851
852852
.. c:function:: Py_ssize_t PyUnicode_AsWideChar(PyObject *unicode, wchar_t *w, Py_ssize_t size)
853853
854-
Copy the Unicode object contents into the :c:expr:`wchar_t` buffer *w*. At most
855-
*size* :c:expr:`wchar_t` characters are copied (excluding a possibly trailing
856-
null termination character). Return the number of :c:expr:`wchar_t` characters
854+
Copy the Unicode object contents into the :c:type:`wchar_t` buffer *w*. At most
855+
*size* :c:type:`wchar_t` characters are copied (excluding a possibly trailing
856+
null termination character). Return the number of :c:type:`wchar_t` characters
857857
copied or ``-1`` in case of an error. Note that the resulting :c:expr:`wchar_t*`
858858
string may or may not be null-terminated. It is the responsibility of the caller
859859
to make sure that the :c:expr:`wchar_t*` string is null-terminated in case this is
@@ -867,7 +867,7 @@ wchar_t Support
867867
Convert the Unicode object to a wide character string. The output string
868868
always ends with a null character. If *size* is not ``NULL``, write the number
869869
of wide characters (excluding the trailing null termination character) into
870-
*\*size*. Note that the resulting :c:expr:`wchar_t` string might contain
870+
*\*size*. Note that the resulting :c:type:`wchar_t` string might contain
871871
null characters, which would cause the string to be truncated when used with
872872
most C functions. If *size* is ``NULL`` and the :c:expr:`wchar_t*` string
873873
contains null characters a :exc:`ValueError` is raised.

Doc/c-api/veryhigh.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ parameter. The available start symbols are :c:data:`Py_eval_input`,
1717
following the functions which accept them as parameters.
1818

1919
Note also that several of these functions take :c:expr:`FILE*` parameters. One
20-
particular issue which needs to be handled carefully is that the :c:expr:`FILE`
20+
particular issue which needs to be handled carefully is that the :c:type:`FILE`
2121
structure for different C libraries can be different and incompatible. Under
2222
Windows (at least), it is possible for dynamically linked extensions to actually
2323
use different libraries, so care should be taken that :c:expr:`FILE*` parameters

Doc/conf.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,76 @@
7777
exclude_patterns.append(venvdir + '/*')
7878

7979
nitpick_ignore = [
80+
# Standard C functions
81+
('c:func', 'calloc'),
82+
('c:func', 'dlopen'),
83+
('c:func', 'exec'),
84+
('c:func', 'fcntl'),
85+
('c:func', 'fork'),
86+
('c:func', 'free'),
87+
('c:func', 'gmtime'),
88+
('c:func', 'localtime'),
89+
('c:func', 'main'),
90+
('c:func', 'malloc'),
91+
('c:func', 'printf'),
92+
('c:func', 'realloc'),
93+
('c:func', 'snprintf'),
94+
('c:func', 'sprintf'),
95+
('c:func', 'stat'),
96+
('c:func', 'system'),
97+
('c:func', 'vsnprintf'),
98+
# Standard C types
99+
('c:type', 'FILE'),
100+
('c:type', '__int'),
101+
('c:type', 'intmax_t'),
102+
('c:type', 'off_t'),
103+
('c:type', 'ptrdiff_t'),
104+
('c:type', 'siginfo_t'),
105+
('c:type', 'size_t'),
106+
('c:type', 'ssize_t'),
107+
('c:type', 'time_t'),
108+
('c:type', 'uintmax_t'),
109+
('c:type', 'va_list'),
110+
('c:type', 'wchar_t'),
111+
# Standard C macros
112+
('c:macro', 'LLONG_MAX'),
113+
('c:macro', 'LLONG_MIN'),
114+
('c:macro', 'LONG_MAX'),
115+
('c:macro', 'LONG_MIN'),
116+
# Standard C variables
117+
('c:data', 'errno'),
118+
# Standard environment variables
119+
('envvar', 'BROWSER'),
120+
('envvar', 'COLUMNS'),
121+
('envvar', 'COMSPEC'),
122+
('envvar', 'DISPLAY'),
123+
('envvar', 'HOME'),
124+
('envvar', 'HOMEDRIVE'),
125+
('envvar', 'HOMEPATH'),
126+
('envvar', 'IDLESTARTUP'),
127+
('envvar', 'LANG'),
128+
('envvar', 'LANGUAGE'),
129+
('envvar', 'LC_ALL'),
130+
('envvar', 'LC_CTYPE'),
131+
('envvar', 'LC_COLLATE'),
132+
('envvar', 'LC_MESSAGES'),
133+
('envvar', 'LC_MONETARY'),
134+
('envvar', 'LC_NUMERIC'),
135+
('envvar', 'LC_TIME'),
136+
('envvar', 'LINES'),
137+
('envvar', 'LOGNAME'),
138+
('envvar', 'PAGER'),
139+
('envvar', 'PATH'),
140+
('envvar', 'PATHEXT'),
141+
('envvar', 'SOURCE_DATE_EPOCH'),
142+
('envvar', 'TEMP'),
143+
('envvar', 'TERM'),
144+
('envvar', 'TMP'),
145+
('envvar', 'TMPDIR'),
146+
('envvar', 'TZ'),
147+
('envvar', 'USER'),
148+
('envvar', 'USERNAME'),
149+
('envvar', 'USERPROFILE'),
80150
# Do not error nit-picky mode builds when _SubParsersAction.add_parser cannot
81151
# be resolved, as the method is currently undocumented. For context, see
82152
# https://github.com/python/cpython/pull/103289.

0 commit comments

Comments
 (0)