Skip to content

Commit 429865a

Browse files
Merge branch 'main' into wip-open-encoding
2 parents bbd2001 + 11e865c commit 429865a

File tree

826 files changed

+10650
-5572
lines changed

Some content is hidden

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

826 files changed

+10650
-5572
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ Python/pythonrun.c @iritkatriel
5353
/Lib/html/ @ezio-melotti
5454
/Lib/_markupbase.py @ezio-melotti
5555
/Lib/test/test_html*.py @ezio-melotti
56+
/Tools/scripts/*html5* @ezio-melotti
5657

5758
# Import (including importlib).
5859
# Ignoring importlib.h so as to not get flagged on
5960
# all pull requests that change the emitted
6061
# bytecode.
6162
**/*import*.c @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
6263
**/*import*.py @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
64+
**/importlib/resources/* @jaraco @warsaw @brettcannon
65+
**/importlib/metadata/* @jaraco @warsaw
6366

6467
# Dates and times
6568
**/*datetime* @pganssle @abalkin
@@ -95,7 +98,7 @@ Lib/ast.py @isidentical
9598

9699
# Mock
97100
/Lib/unittest/mock.py @cjw296
98-
/Lib/unittest/test/testmock/* @cjw296
101+
/Lib/test/test_unittest/testmock/* @cjw296
99102

100103
# SQLite 3
101104
**/*sqlite* @berkerpeksag @erlend-aasland

.github/workflows/doc.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
paths:
2424
- 'Doc/**'
2525
- 'Misc/**'
26+
- '.github/workflows/doc.yml'
2627

2728
permissions:
2829
contents: read
@@ -35,6 +36,38 @@ jobs:
3536
- uses: actions/checkout@v3
3637
- name: Register Sphinx problem matcher
3738
run: echo "::add-matcher::.github/problem-matchers/sphinx.json"
39+
- name: 'Set up Python'
40+
uses: actions/setup-python@v4
41+
with:
42+
python-version: '3'
43+
cache: 'pip'
44+
cache-dependency-path: 'Doc/requirements.txt'
45+
- name: 'Install build dependencies'
46+
run: make -C Doc/ venv
47+
- name: 'Check documentation'
48+
run: make -C Doc/ check
49+
- name: 'Build HTML documentation'
50+
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
51+
- name: 'Upload'
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: doc-html
55+
path: Doc/build/html
56+
57+
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
58+
doctest:
59+
name: 'Doctest'
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v3
63+
- name: Register Sphinx problem matcher
64+
run: echo "::add-matcher::.github/problem-matchers/sphinx.json"
65+
- uses: actions/cache@v3
66+
with:
67+
path: ~/.cache/pip
68+
key: ubuntu-doc-${{ hashFiles('Doc/requirements.txt') }}
69+
restore-keys: |
70+
ubuntu-doc-
3871
- name: 'Install Dependencies'
3972
run: sudo ./.github/workflows/posix-deps-apt.sh && sudo apt-get install wamerican
4073
- name: 'Configure CPython'
@@ -43,17 +76,6 @@ jobs:
4376
run: make -j4
4477
- name: 'Install build dependencies'
4578
run: make -C Doc/ PYTHON=../python venv
46-
# Run "check doctest html" as 3 steps to get a more readable output
47-
# in the web UI
48-
- name: 'Check documentation'
49-
run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going" check
5079
# Use "xvfb-run" since some doctest tests open GUI windows
5180
- name: 'Run documentation doctest'
52-
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going" doctest
53-
- name: 'Build HTML documentation'
54-
run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going" html
55-
- name: 'Upload'
56-
uses: actions/upload-artifact@v3
57-
with:
58-
name: doc-html
59-
path: Doc/build/html
81+
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" doctest
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Verify bundled pip and setuptools
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- 'Lib/ensurepip/_bundled/**'
8+
- '.github/workflows/verify-ensurepip-wheels.yml'
9+
- 'Tools/scripts/verify_ensurepip_wheels.py'
10+
pull_request:
11+
paths:
12+
- 'Lib/ensurepip/_bundled/**'
13+
- '.github/workflows/verify-ensurepip-wheels.yml'
14+
- 'Tools/scripts/verify_ensurepip_wheels.py'
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
verify:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-python@v4
25+
with:
26+
python-version: '3'
27+
- name: Compare checksums of bundled pip and setuptools to ones published on PyPI
28+
run: ./Tools/scripts/verify_ensurepip_wheels.py

Doc/c-api/bytes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ called with a non-bytes parameter.
5858
5959
.. % XXX: This should be exactly the same as the table in PyErr_Format.
6060
.. % One should just refer to the other.
61-
.. % XXX: The descriptions for %zd and %zu are wrong, but the truth is complicated
62-
.. % because not all compilers support the %z width modifier -- we fake it
63-
.. % when necessary via interpolating PY_FORMAT_SIZE_T.
6461
6562
.. tabularcolumns:: |l|l|L|
6663

Doc/c-api/call.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ Vectorcall Support API
144144
However, the function ``PyVectorcall_NARGS`` should be used to allow
145145
for future extensions.
146146
147-
This function is not part of the :ref:`limited API <stable>`.
148-
149147
.. versionadded:: 3.8
150148
151149
.. c:function:: vectorcallfunc PyVectorcall_Function(PyObject *op)
@@ -158,8 +156,6 @@ Vectorcall Support API
158156
This is mostly useful to check whether or not *op* supports vectorcall,
159157
which can be done by checking ``PyVectorcall_Function(op) != NULL``.
160158
161-
This function is not part of the :ref:`limited API <stable>`.
162-
163159
.. versionadded:: 3.8
164160
165161
.. c:function:: PyObject* PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict)
@@ -172,8 +168,6 @@ Vectorcall Support API
172168
It does not check the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag
173169
and it does not fall back to ``tp_call``.
174170
175-
This function is not part of the :ref:`limited API <stable>`.
176-
177171
.. versionadded:: 3.8
178172
179173
@@ -256,8 +250,6 @@ please see individual documentation for details.
256250
Return the result of the call on success, or raise an exception and return
257251
*NULL* on failure.
258252
259-
This function is not part of the :ref:`limited API <stable>`.
260-
261253
.. versionadded:: 3.9
262254
263255
@@ -343,8 +335,6 @@ please see individual documentation for details.
343335
Return the result of the call on success, or raise an exception and return
344336
*NULL* on failure.
345337
346-
This function is not part of the :ref:`limited API <stable>`.
347-
348338
.. versionadded:: 3.9
349339
350340
@@ -357,8 +347,6 @@ please see individual documentation for details.
357347
Return the result of the call on success, or raise an exception and return
358348
*NULL* on failure.
359349
360-
This function is not part of the :ref:`limited API <stable>`.
361-
362350
.. versionadded:: 3.9
363351
364352
@@ -372,8 +360,6 @@ please see individual documentation for details.
372360
Return the result of the call on success, or raise an exception and return
373361
*NULL* on failure.
374362
375-
This function is not part of the :ref:`limited API <stable>`.
376-
377363
.. versionadded:: 3.9
378364
379365
.. c:function:: PyObject* PyObject_VectorcallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict)
@@ -388,8 +374,6 @@ please see individual documentation for details.
388374
already has a dictionary ready to use for the keyword arguments,
389375
but not a tuple for the positional arguments.
390376
391-
This function is not part of the :ref:`limited API <stable>`.
392-
393377
.. versionadded:: 3.9
394378
395379
.. c:function:: PyObject* PyObject_VectorcallMethod(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames)
@@ -410,8 +394,6 @@ please see individual documentation for details.
410394
Return the result of the call on success, or raise an exception and return
411395
*NULL* on failure.
412396
413-
This function is not part of the :ref:`limited API <stable>`.
414-
415397
.. versionadded:: 3.9
416398
417399

Doc/c-api/init_config.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,9 +735,8 @@ PyConfig
735735
736736
* ``"utf-8"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero.
737737
* ``"ascii"`` if Python detects that ``nl_langinfo(CODESET)`` announces
738-
the ASCII encoding (or Roman8 encoding on HP-UX), whereas the
739-
``mbstowcs()`` function decodes from a different encoding (usually
740-
Latin1).
738+
the ASCII encoding, whereas the ``mbstowcs()`` function
739+
decodes from a different encoding (usually Latin1).
741740
* ``"utf-8"`` if ``nl_langinfo(CODESET)`` returns an empty string.
742741
* Otherwise, use the :term:`locale encoding`:
743742
``nl_langinfo(CODESET)`` result.

Doc/c-api/structures.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ There are these calling conventions:
321321
or possibly ``NULL`` if there are no keywords. The values of the keyword
322322
arguments are stored in the *args* array, after the positional arguments.
323323
324-
This is not part of the :ref:`limited API <stable>`.
325-
326324
.. versionadded:: 3.7
327325
328326

Doc/c-api/sys.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ Operating System Utilities
2121
2222
Return true (nonzero) if the standard I/O file *fp* with name *filename* is
2323
deemed interactive. This is the case for files for which ``isatty(fileno(fp))``
24-
is true. If the global flag :c:data:`Py_InteractiveFlag` is true, this function
24+
is true. If the :c:member:`PyConfig.interactive` is non-zero, this function
2525
also returns true if the *filename* pointer is ``NULL`` or if the name is equal to
2626
one of the strings ``'<stdin>'`` or ``'???'``.
2727
28+
This function must not be called before Python is initialized.
29+
2830
2931
.. c:function:: void PyOS_BeforeFork()
3032

Doc/c-api/type.rst

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,16 @@ Creating Heap-Allocated Types
190190
The following functions and structs are used to create
191191
:ref:`heap types <heap-types>`.
192192
193-
.. c:function:: PyObject* PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
193+
.. c:function:: PyObject* PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases)
194+
195+
Create and return a :ref:`heap type <heap-types>` from the *spec*
196+
(see :const:`Py_TPFLAGS_HEAPTYPE`).
194197
195-
Creates and returns a :ref:`heap type <heap-types>` from the *spec*
196-
(:const:`Py_TPFLAGS_HEAPTYPE`).
198+
The metaclass *metaclass* is used to construct the resulting type object.
199+
When *metaclass* is ``NULL``, the metaclass is derived from *bases*
200+
(or *Py_tp_base[s]* slots if *bases* is ``NULL``, see below).
201+
Note that metaclasses that override
202+
:c:member:`~PyTypeObject.tp_new` are not supported.
197203
198204
The *bases* argument can be used to specify base classes; it can either
199205
be only one class or a tuple of classes.
@@ -210,22 +216,58 @@ The following functions and structs are used to create
210216
211217
This function calls :c:func:`PyType_Ready` on the new type.
212218
219+
Note that this function does *not* fully match the behavior of
220+
calling :py:class:`type() <type>` or using the :keyword:`class` statement.
221+
With user-provided base types or metaclasses, prefer
222+
:ref:`calling <capi-call>` :py:class:`type` (or the metaclass)
223+
over ``PyType_From*`` functions.
224+
Specifically:
225+
226+
* :py:meth:`~object.__new__` is not called on the new class
227+
(and it must be set to ``type.__new__``).
228+
* :py:meth:`~object.__init__` is not called on the new class.
229+
* :py:meth:`~object.__init_subclass__` is not called on any bases.
230+
* :py:meth:`~object.__set_name__` is not called on new descriptors.
231+
232+
.. versionadded:: 3.12
233+
234+
.. c:function:: PyObject* PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
235+
236+
Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``.
237+
213238
.. versionadded:: 3.9
214239
215240
.. versionchanged:: 3.10
216241
217242
The function now accepts a single class as the *bases* argument and
218243
``NULL`` as the ``tp_doc`` slot.
219244
245+
.. versionchanged:: 3.12
246+
247+
The function now finds and uses a metaclass corresponding to the provided
248+
base classes. Previously, only :class:`type` instances were returned.
249+
250+
220251
.. c:function:: PyObject* PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
221252
222-
Equivalent to ``PyType_FromModuleAndSpec(NULL, spec, bases)``.
253+
Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``.
223254
224255
.. versionadded:: 3.3
225256
257+
.. versionchanged:: 3.12
258+
259+
The function now finds and uses a metaclass corresponding to the provided
260+
base classes. Previously, only :class:`type` instances were returned.
261+
226262
.. c:function:: PyObject* PyType_FromSpec(PyType_Spec *spec)
227263
228-
Equivalent to ``PyType_FromSpecWithBases(spec, NULL)``.
264+
Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``.
265+
266+
.. versionchanged:: 3.12
267+
268+
The function now finds and uses a metaclass corresponding to the
269+
base classes provided in *Py_tp_base[s]* slots.
270+
Previously, only :class:`type` instances were returned.
229271
230272
.. c:type:: PyType_Spec
231273
@@ -254,6 +296,8 @@ The following functions and structs are used to create
254296
Array of :c:type:`PyType_Slot` structures.
255297
Terminated by the special slot value ``{0, NULL}``.
256298
299+
Each slot ID should be specified at most once.
300+
257301
.. c:type:: PyType_Slot
258302
259303
Structure defining optional functionality of a type, containing a slot ID

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,6 @@ and :c:type:`PyType_Type` effectively act as defaults.)
727727
When a user sets :attr:`__call__` in Python code, only *tp_call* is updated,
728728
likely making it inconsistent with the vectorcall function.
729729

730-
.. note::
731-
732-
The semantics of the ``tp_vectorcall_offset`` slot are provisional and
733-
expected to be finalized in Python 3.9.
734-
If you use vectorcall, plan for updating your code for Python 3.9.
735-
736730
.. versionchanged:: 3.8
737731

738732
Before version 3.8, this slot was named ``tp_print``.
@@ -2071,7 +2065,7 @@ flag set.
20712065

20722066
This is done by filling a :c:type:`PyType_Spec` structure and calling
20732067
:c:func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases`,
2074-
or :c:func:`PyType_FromModuleAndSpec`.
2068+
:c:func:`PyType_FromModuleAndSpec`, or :c:func:`PyType_FromMetaclass`.
20752069

20762070

20772071
.. _number-structs:

Doc/c-api/unicode.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,6 @@ APIs:
397397
ASCII-encoded string. The following format characters are allowed:
398398
399399
.. % This should be exactly the same as the table in PyErr_Format.
400-
.. % The descriptions for %zd and %zu are wrong, but the truth is complicated
401-
.. % because not all compilers support the %z width modifier -- we fake it
402-
.. % when necessary via interpolating PY_FORMAT_SIZE_T.
403-
.. % Similar comments apply to the %ll width modifier and
404400
405401
.. tabularcolumns:: |l|l|L|
406402

Doc/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
highlight_language = 'python3'
4646

4747
# Minimum version of sphinx required
48-
needs_sphinx = '1.8'
48+
needs_sphinx = '3.2'
4949

5050
# Ignore any .rst files in the venv/ directory.
5151
exclude_patterns = ['venv/*', 'README.rst']
@@ -237,5 +237,3 @@
237237
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
238238
# documentation is built with -W (warnings treated as errors).
239239
c_warn_on_allowed_pre_v3 = False
240-
241-
strip_signature_backslash = True

Doc/data/stable_abi.dat

Lines changed: 1 addition & 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)