Skip to content

Commit 321137e

Browse files
authored
Merge branch '3.12' into gh-89811-3.12-backport
2 parents 4393350 + 2c9cf64 commit 321137e

File tree

342 files changed

+4106
-2268
lines changed

Some content is hidden

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

342 files changed

+4106
-2268
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ jobs:
169169
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
170170
- name: Configure ccache action
171171
uses: hendrikmuhs/[email protected]
172+
with:
173+
save: false
172174
- name: Check Autoconf and aclocal versions
173175
run: |
174176
grep "Generated by GNU Autoconf 2.71" configure
@@ -283,6 +285,8 @@ jobs:
283285
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
284286
- name: Configure ccache action
285287
uses: hendrikmuhs/[email protected]
288+
with:
289+
save: false
286290
- name: Configure CPython
287291
run: ./configure --config-cache --with-pydebug --with-openssl=$OPENSSL_DIR
288292
- name: Build CPython
@@ -326,6 +330,8 @@ jobs:
326330
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
327331
- name: Configure ccache action
328332
uses: hendrikmuhs/[email protected]
333+
with:
334+
save: false
329335
- name: Setup directory envs for out-of-tree builds
330336
run: |
331337
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
@@ -445,6 +451,9 @@ jobs:
445451
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
446452
- name: Configure ccache action
447453
uses: hendrikmuhs/[email protected]
454+
with:
455+
save: ${{ github.event_name == 'push' }}
456+
max-size: "200M"
448457
- name: Configure CPython
449458
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
450459
- name: Build CPython

.github/workflows/reusable-macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
config_hash:
55
required: true
66
type: string
7-
free-threaded:
7+
free-threading:
88
required: false
99
type: boolean
1010
default: false
@@ -35,7 +35,7 @@ jobs:
3535
./configure \
3636
--config-cache \
3737
--with-pydebug \
38-
${{ inputs.free-threaded && '--disable-gil' || '' }} \
38+
${{ inputs.free-threading && '--disable-gil' || '' }} \
3939
--prefix=/opt/python-dev \
4040
--with-openssl="$(brew --prefix [email protected])"
4141
- name: Build CPython

.github/workflows/reusable-ubuntu.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
4242
- name: Configure ccache action
4343
uses: hendrikmuhs/[email protected]
44+
with:
45+
save: ${{ github.event_name == 'push' }}
46+
max-size: "200M"
4447
- name: Setup directory envs for out-of-tree builds
4548
run: |
4649
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV

.github/workflows/reusable-windows.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
workflow_call:
33
inputs:
4-
free-threaded:
4+
free-threading:
55
required: false
66
type: boolean
77
default: false
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Build CPython
19-
run: .\PCbuild\build.bat -e -d -p Win32 ${{ inputs.free-threaded && '--disable-gil' || '' }}
19+
run: .\PCbuild\build.bat -e -d -p Win32 ${{ inputs.free-threading && '--disable-gil' || '' }}
2020
- name: Display build info
2121
run: .\python.bat -m test.pythoninfo
2222
- name: Tests
@@ -33,7 +33,7 @@ jobs:
3333
- name: Register MSVC problem matcher
3434
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3535
- name: Build CPython
36-
run: .\PCbuild\build.bat -e -d -p x64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
36+
run: .\PCbuild\build.bat -e -d -p x64 ${{ inputs.free-threading && '--disable-gil' || '' }}
3737
- name: Display build info
3838
run: .\python.bat -m test.pythoninfo
3939
- name: Tests
@@ -50,4 +50,4 @@ jobs:
5050
- name: Register MSVC problem matcher
5151
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
5252
- name: Build CPython
53-
run: .\PCbuild\build.bat -e -d -p arm64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
53+
run: .\PCbuild\build.bat -e -d -p arm64 ${{ inputs.free-threading && '--disable-gil' || '' }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
hooks:
2929
- id: sphinx-lint
3030
args: [--enable=default-role]
31-
files: ^Doc/|^Misc/NEWS.d/next/
31+
files: ^Doc/|^Misc/NEWS.d/
3232

3333
- repo: meta
3434
hooks:

Doc/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ SPHINXERRORHANDLING = -W
1919
PAPEROPT_a4 = -D latex_elements.papersize=a4paper
2020
PAPEROPT_letter = -D latex_elements.papersize=letterpaper
2121

22-
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j $(JOBS) \
23-
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
22+
ALLSPHINXOPTS = -b $(BUILDER) \
23+
-d build/doctrees \
24+
-j $(JOBS) \
25+
$(PAPEROPT_$(PAPER)) \
26+
$(SPHINXOPTS) $(SPHINXERRORHANDLING) \
27+
. build/$(BUILDER) $(SOURCES)
2428

2529
.PHONY: help
2630
help:
@@ -142,7 +146,7 @@ htmlview: html
142146

143147
.PHONY: htmllive
144148
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
145-
htmllive: SPHINXOPTS = --re-ignore="/venv/"
149+
htmllive: SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
146150
htmllive: html
147151

148152
.PHONY: clean

Doc/c-api/bytes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ called with a non-bytes parameter.
155155
156156
Return the null-terminated contents of the object *obj*
157157
through the output variables *buffer* and *length*.
158+
Returns ``0`` on success.
158159
159160
If *length* is ``NULL``, the bytes object
160161
may not contain embedded null bytes;

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Querying the error indicator
427427
.. c:function:: PyObject *PyErr_GetRaisedException(void)
428428
429429
Return the exception currently being raised, clearing the error indicator at
430-
the same time.
430+
the same time. Return ``NULL`` if the error indicator is not set.
431431
432432
This function is used by code that needs to catch exceptions,
433433
or code that needs to save and restore the error indicator temporarily.

Doc/c-api/structures.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,40 @@ definition with the same method name.
399399
slot. This is helpful because calls to PyCFunctions are optimized more
400400
than wrapper object calls.
401401
402+
.. c:function:: PyObject * PyCMethod_New(PyMethodDef *ml, PyObject *self, PyObject *module, PyTypeObject *cls)
403+
404+
Turn *ml* into a Python :term:`callable` object.
405+
The caller must ensure that *ml* outlives the :term:`callable`.
406+
Typically, *ml* is defined as a static variable.
407+
408+
The *self* parameter will be passed as the *self* argument
409+
to the C function in ``ml->ml_meth`` when invoked.
410+
*self* can be ``NULL``.
411+
412+
The :term:`callable` object's ``__module__`` attribute
413+
can be set from the given *module* argument.
414+
*module* should be a Python string,
415+
which will be used as name of the module the function is defined in.
416+
If unavailable, it can be set to :const:`None` or ``NULL``.
417+
418+
.. seealso:: :attr:`function.__module__`
419+
420+
The *cls* parameter will be passed as the *defining_class*
421+
argument to the C function.
422+
Must be set if :c:macro:`METH_METHOD` is set on ``ml->ml_flags``.
423+
424+
.. versionadded:: 3.9
425+
426+
427+
.. c:function:: PyObject * PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
428+
429+
Equivalent to ``PyCMethod_New(ml, self, module, NULL)``.
430+
431+
432+
.. c:function:: PyObject * PyCFunction_New(PyMethodDef *ml, PyObject *self)
433+
434+
Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``.
435+
402436
403437
Accessing attributes of extension types
404438
---------------------------------------

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@
242242
# Attributes/methods/etc. that definitely should be documented better,
243243
# but are deferred for now:
244244
('py:attr', '__annotations__'),
245+
('py:meth', '__missing__'),
245246
('py:attr', '__wrapped__'),
246247
('py:meth', 'index'), # list.index, tuple.index, etc.
247248
]

Doc/constraints.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ packaging<24
1313
Pygments>=2.16.1,<3
1414
requests<3
1515
snowballstemmer<3
16-
sphinxcontrib-applehelp<1.1
17-
sphinxcontrib-devhelp<1.1
18-
sphinxcontrib-htmlhelp<2.1
16+
sphinxcontrib-applehelp<1.0.5
17+
sphinxcontrib-devhelp<1.0.6
18+
sphinxcontrib-htmlhelp<2.0.5
1919
sphinxcontrib-jsmath<1.1
20-
sphinxcontrib-qthelp<1.1
21-
sphinxcontrib-serializinghtml<1.2
20+
sphinxcontrib-qthelp<1.0.7
21+
sphinxcontrib-serializinghtml<1.1.10
2222

2323
# Direct dependencies of Jinja2 (Jinja is a dependency of Sphinx, see above)
2424
MarkupSafe<2.2

Doc/data/refcounts.dat

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,21 @@ PyContextVar_Reset:int:::
402402
PyContextVar_Reset:PyObject*:var:0:
403403
PyContextVar_Reset:PyObject*:token:-1:
404404

405+
PyCFunction_New:PyObject*::+1:
406+
PyCFunction_New:PyMethodDef*:ml::
407+
PyCFunction_New:PyObject*:self:+1:
408+
409+
PyCFunction_NewEx:PyObject*::+1:
410+
PyCFunction_NewEx:PyMethodDef*:ml::
411+
PyCFunction_NewEx:PyObject*:self:+1:
412+
PyCFunction_NewEx:PyObject*:module:+1:
413+
414+
PyCMethod_New:PyObject*::+1:
415+
PyCMethod_New:PyMethodDef*:ml::
416+
PyCMethod_New:PyObject*:self:+1:
417+
PyCMethod_New:PyObject*:module:+1:
418+
PyCMethod_New:PyObject*:cls:+1:
419+
405420
PyDate_Check:int:::
406421
PyDate_Check:PyObject*:ob:0:
407422

@@ -1607,6 +1622,13 @@ PyObject_Call:PyObject*:callable_object:0:
16071622
PyObject_Call:PyObject*:args:0:
16081623
PyObject_Call:PyObject*:kw:0:
16091624

1625+
PyObject_CallNoArgs:PyObject*::+1:
1626+
PyObject_CallNoArgs:PyObject*:callable_object:0:
1627+
1628+
PyObject_CallOneArg:PyObject*::+1:
1629+
PyObject_CallOneArg:PyObject*:callable_object:0:
1630+
PyObject_CallOneArg:PyObject*:arg:0:
1631+
16101632
PyObject_CallFunction:PyObject*::+1:
16111633
PyObject_CallFunction:PyObject*:callable_object:0:
16121634
PyObject_CallFunction:const char*:format::

Doc/faq/design.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ on the key and a per-process seed; for example, ``'Python'`` could hash to
451451
to ``1142331976``. The hash code is then used to calculate a location in an
452452
internal array where the value will be stored. Assuming that you're storing
453453
keys that all have different hash values, this means that dictionaries take
454-
constant time -- O(1), in Big-O notation -- to retrieve a key.
454+
constant time -- *O*\ (1), in Big-O notation -- to retrieve a key.
455455

456456

457457
Why must dictionary keys be immutable?

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ Glossary
741741
list
742742
A built-in Python :term:`sequence`. Despite its name it is more akin
743743
to an array in other languages than to a linked list since access to
744-
elements is O(1).
744+
elements is *O*\ (1).
745745

746746
list comprehension
747747
A compact way to process all or part of the elements in a sequence and

Doc/howto/descriptor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ instance::
12401240
<function D.f at 0x00C45070>
12411241

12421242
>>> d.f.__self__
1243-
<__main__.D object at 0x1012e1f98>
1243+
<__main__.D object at 0x00B18C90>
12441244

12451245
If you have ever wondered where *self* comes from in regular methods or where
12461246
*cls* comes from in class methods, this is it!

Doc/howto/isolating-extensions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ That is, heap types should:
337337

338338
- Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag.
339339
- Define a traverse function using ``Py_tp_traverse``, which
340-
visits the type (e.g. using :c:expr:`Py_VISIT(Py_TYPE(self))`).
340+
visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).
341341

342342
Please refer to the the documentation of
343343
:c:macro:`Py_TPFLAGS_HAVE_GC` and :c:member:`~PyTypeObject.tp_traverse`
@@ -482,7 +482,7 @@ The largest roadblock is getting *the class a method was defined in*, or
482482
that method's "defining class" for short. The defining class can have a
483483
reference to the module it is part of.
484484

485-
Do not confuse the defining class with :c:expr:`Py_TYPE(self)`. If the method
485+
Do not confuse the defining class with ``Py_TYPE(self)``. If the method
486486
is called on a *subclass* of your type, ``Py_TYPE(self)`` will refer to
487487
that subclass, which may be defined in different module than yours.
488488

Doc/howto/urllib2.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,16 @@ info and geturl
392392
===============
393393

394394
The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` instance) has two
395-
useful methods :meth:`info` and :meth:`geturl` and is defined in the module
396-
:mod:`urllib.response`..
395+
useful methods :meth:`!info` and :meth:`!geturl` and is defined in the module
396+
:mod:`urllib.response`.
397397

398-
**geturl** - this returns the real URL of the page fetched. This is useful
399-
because ``urlopen`` (or the opener object used) may have followed a
400-
redirect. The URL of the page fetched may not be the same as the URL requested.
398+
* **geturl** - this returns the real URL of the page fetched. This is useful
399+
because ``urlopen`` (or the opener object used) may have followed a
400+
redirect. The URL of the page fetched may not be the same as the URL requested.
401401

402-
**info** - this returns a dictionary-like object that describes the page
403-
fetched, particularly the headers sent by the server. It is currently an
404-
:class:`http.client.HTTPMessage` instance.
402+
* **info** - this returns a dictionary-like object that describes the page
403+
fetched, particularly the headers sent by the server. It is currently an
404+
:class:`http.client.HTTPMessage` instance.
405405

406406
Typical headers include 'Content-length', 'Content-type', and so on. See the
407407
`Quick Reference to HTTP Headers <https://jkorpela.fi/http.html>`_
@@ -507,7 +507,7 @@ than the URL you pass to .add_password() will also match. ::
507507

508508
In the above example we only supplied our ``HTTPBasicAuthHandler`` to
509509
``build_opener``. By default openers have the handlers for normal situations
510-
-- ``ProxyHandler`` (if a proxy setting such as an :envvar:`http_proxy`
510+
-- ``ProxyHandler`` (if a proxy setting such as an :envvar:`!http_proxy`
511511
environment variable is set), ``UnknownHandler``, ``HTTPHandler``,
512512
``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
513513
``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``.

0 commit comments

Comments
 (0)