Skip to content

Commit 34dfe5a

Browse files
authored
Merge branch 'main' into fix-issue-87597
2 parents 39393a8 + 3ef3c63 commit 34dfe5a

419 files changed

Lines changed: 17638 additions & 4444 deletions

File tree

Some content is hidden

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

‎.github/CONTRIBUTING.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Build Status
66

77
- main
88

9-
+ `Stable buildbots <http://buildbot.python.org/3.x.stable/>`_
9+
+ `Stable buildbots <https://buildbot.python.org/3.x.stable/>`_
1010

1111
- 3.9
1212

13-
+ `Stable buildbots <http://buildbot.python.org/3.9.stable/>`_
13+
+ `Stable buildbots <https://buildbot.python.org/3.9.stable/>`_
1414

1515
- 3.8
1616

17-
+ `Stable buildbots <http://buildbot.python.org/3.8.stable/>`_
17+
+ `Stable buildbots <https://buildbot.python.org/3.8.stable/>`_
1818

1919
- 3.7
2020

21-
+ `Stable buildbots <http://buildbot.python.org/3.7.stable/>`_
21+
+ `Stable buildbots <https://buildbot.python.org/3.7.stable/>`_
2222

2323

2424
Thank You

‎Doc/about.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ About these documents
66
These documents are generated from `reStructuredText`_ sources by `Sphinx`_, a
77
document processor specifically written for the Python documentation.
88

9-
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
9+
.. _reStructuredText: https://docutils.sourceforge.io/rst.html
1010
.. _Sphinx: http://sphinx-doc.org/
1111

1212
.. In the online version of these documents, you can submit comments and suggest
@@ -21,7 +21,7 @@ Many thanks go to:
2121

2222
* Fred L. Drake, Jr., the creator of the original Python documentation toolset
2323
and writer of much of the content;
24-
* the `Docutils <http://docutils.sourceforge.net/>`_ project for creating
24+
* the `Docutils <https://docutils.sourceforge.io/>`_ project for creating
2525
reStructuredText and the Docutils suite;
2626
* Fredrik Lundh for his Alternative Python Reference project from which Sphinx
2727
got many good ideas.

‎Doc/c-api/call.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ This bears repeating:
5757
A class supporting vectorcall **must** also implement
5858
:c:member:`~PyTypeObject.tp_call` with the same semantics.
5959

60+
.. versionchanged:: 3.12
61+
62+
The :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag is now removed from a class
63+
when the class's :py:meth:`~object.__call__` method is reassigned.
64+
(This internally sets :c:member:`~PyTypeObject.tp_call` only, and thus
65+
may make it behave differently than the vectorcall function.)
66+
In earlier Python versions, vectorcall should only be used with
67+
:const:`immutable <Py_TPFLAGS_IMMUTABLETYPE>` or static types.
68+
6069
A class should not implement vectorcall if that would be slower
6170
than *tp_call*. For example, if the callee needs to convert
6271
the arguments to an args tuple and kwargs dict anyway, then there is no point

‎Doc/c-api/code.rst‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,28 @@ bound into a function.
9090
9191
.. versionadded:: 3.11
9292
93+
.. c:function:: PyObject* PyCode_GetVarnames(PyCodeObject *co)
94+
95+
Equivalent to the Python code ``getattr(co, 'co_varnames')``.
96+
Returns a new reference to a :c:type:`PyTupleObject` containing the names of
97+
the local variables. On error, ``NULL`` is returned and an exception
98+
is raised.
99+
100+
.. versionadded:: 3.11
101+
102+
.. c:function:: PyObject* PyCode_GetCellvars(PyCodeObject *co)
103+
104+
Equivalent to the Python code ``getattr(co, 'co_cellvars')``.
105+
Returns a new reference to a :c:type:`PyTupleObject` containing the names of
106+
the local variables that are referenced by nested functions. On error, ``NULL``
107+
is returned and an exception is raised.
108+
109+
.. versionadded:: 3.11
110+
111+
.. c:function:: PyObject* PyCode_GetFreevars(PyCodeObject *co)
112+
113+
Equivalent to the Python code ``getattr(co, 'co_freevars')``.
114+
Returns a new reference to a :c:type:`PyTupleObject` containing the names of
115+
the free variables. On error, ``NULL`` is returned and an exception is raised.
116+
117+
.. versionadded:: 3.11

‎Doc/c-api/object.rst‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ Object Protocol
126126
A generic implementation for the getter of a ``__dict__`` descriptor. It
127127
creates the dictionary if necessary.
128128
129+
This function may also be called to get the :py:attr:`~object.__dict__`
130+
of the object *o*. Pass ``NULL`` for *context* when calling it.
131+
Since this function may need to allocate memory for the
132+
dictionary, it may be more efficient to call :c:func:`PyObject_GetAttr`
133+
when accessing an attribute on the object.
134+
135+
On failure, returns ``NULL`` with an exception set.
136+
129137
.. versionadded:: 3.3
130138
131139
@@ -137,6 +145,16 @@ Object Protocol
137145
.. versionadded:: 3.3
138146
139147
148+
.. c:function:: PyObject** _PyObject_GetDictPtr(PyObject *obj)
149+
150+
Return a pointer to :py:attr:`~object.__dict__` of the object *obj*.
151+
If there is no ``__dict__``, return ``NULL`` without setting an exception.
152+
153+
This function may need to allocate memory for the
154+
dictionary, so it may be more efficient to call :c:func:`PyObject_GetAttr`
155+
when accessing an attribute on the object.
156+
157+
140158
.. c:function:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
141159
142160
Compare the values of *o1* and *o2* using the operation specified by *opid*,

‎Doc/c-api/typeobj.rst‎

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Quick Reference
135135
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
136136
| [:c:member:`~PyTypeObject.tp_cache`] | :c:type:`PyObject` * | | | | |
137137
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
138-
| [:c:member:`~PyTypeObject.tp_subclasses`] | :c:type:`PyObject` * | __subclasses__ | | | |
138+
| [:c:member:`~PyTypeObject.tp_subclasses`] | void * | __subclasses__ | | | |
139139
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
140140
| [:c:member:`~PyTypeObject.tp_weaklist`] | :c:type:`PyObject` * | | | | |
141141
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
@@ -720,29 +720,29 @@ and :c:type:`PyType_Type` effectively act as defaults.)
720720
with the *vectorcallfunc* function.
721721
This can be done by setting *tp_call* to :c:func:`PyVectorcall_Call`.
722722

723-
.. warning::
724-
725-
It is not recommended for :ref:`mutable heap types <heap-types>` to implement
726-
the vectorcall protocol.
727-
When a user sets :attr:`__call__` in Python code, only *tp_call* is updated,
728-
likely making it inconsistent with the vectorcall function.
729-
730723
.. versionchanged:: 3.8
731724

732725
Before version 3.8, this slot was named ``tp_print``.
733726
In Python 2.x, it was used for printing to a file.
734727
In Python 3.0 to 3.7, it was unused.
735728

729+
.. versionchanged:: 3.12
730+
731+
Before version 3.12, it was not recommended for
732+
:ref:`mutable heap types <heap-types>` to implement the vectorcall
733+
protocol.
734+
When a user sets :attr:`~type.__call__` in Python code, only *tp_call* is
735+
updated, likely making it inconsistent with the vectorcall function.
736+
Since 3.12, setting ``__call__`` will disable vectorcall optimization
737+
by clearing the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag.
738+
736739
**Inheritance:**
737740

738741
This field is always inherited.
739742
However, the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag is not
740-
always inherited. If it's not, then the subclass won't use
743+
always inherited. If it's not set, then the subclass won't use
741744
:ref:`vectorcall <vectorcall>`, except when
742745
:c:func:`PyVectorcall_Call` is explicitly called.
743-
This is in particular the case for types without the
744-
:const:`Py_TPFLAGS_IMMUTABLETYPE` flag set (including subclasses defined in
745-
Python).
746746

747747

748748
.. c:member:: getattrfunc PyTypeObject.tp_getattr
@@ -1178,12 +1178,18 @@ and :c:type:`PyType_Type` effectively act as defaults.)
11781178

11791179
**Inheritance:**
11801180

1181-
This bit is inherited for types with the
1182-
:const:`Py_TPFLAGS_IMMUTABLETYPE` flag set, if
1183-
:c:member:`~PyTypeObject.tp_call` is also inherited.
1181+
This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also
1182+
inherited.
11841183

11851184
.. versionadded:: 3.9
11861185

1186+
.. versionchanged:: 3.12
1187+
1188+
This flag is now removed from a class when the class's
1189+
:py:meth:`~object.__call__` method is reassigned.
1190+
1191+
This flag can now be inherited by mutable classes.
1192+
11871193
.. data:: Py_TPFLAGS_IMMUTABLETYPE
11881194

11891195
This bit is set for type objects that are immutable: type attributes cannot be set nor deleted.
@@ -1709,18 +1715,11 @@ and :c:type:`PyType_Type` effectively act as defaults.)
17091715
:c:member:`~PyTypeObject.tp_dictoffset` should be set to ``-4`` to indicate that the dictionary is
17101716
at the very end of the structure.
17111717

1712-
The real dictionary offset in an instance can be computed from a negative
1713-
:c:member:`~PyTypeObject.tp_dictoffset` as follows::
1714-
1715-
dictoffset = tp_basicsize + abs(ob_size)*tp_itemsize + tp_dictoffset
1716-
if dictoffset is not aligned on sizeof(void*):
1717-
round up to sizeof(void*)
1718-
1719-
where :c:member:`~PyTypeObject.tp_basicsize`, :c:member:`~PyTypeObject.tp_itemsize` and :c:member:`~PyTypeObject.tp_dictoffset` are
1720-
taken from the type object, and :attr:`ob_size` is taken from the instance. The
1721-
absolute value is taken because ints use the sign of :attr:`ob_size` to
1722-
store the sign of the number. (There's never a need to do this calculation
1723-
yourself; it is done for you by :c:func:`_PyObject_GetDictPtr`.)
1718+
The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-only.
1719+
To get the pointer to the dictionary call :c:func:`PyObject_GenericGetDict`.
1720+
Calling :c:func:`PyObject_GenericGetDict` may need to allocate memory for the
1721+
dictionary, so it is may be more efficient to call :c:func:`PyObject_GetAttr`
1722+
when accessing an attribute on the object.
17241723

17251724
**Inheritance:**
17261725

@@ -1928,9 +1927,17 @@ and :c:type:`PyType_Type` effectively act as defaults.)
19281927
This field is not inherited.
19291928

19301929

1931-
.. c:member:: PyObject* PyTypeObject.tp_subclasses
1930+
.. c:member:: void* PyTypeObject.tp_subclasses
1931+
1932+
A collection of subclasses. Internal use only. May be an invalid pointer.
1933+
1934+
To get a list of subclasses, call the Python method
1935+
:py:meth:`~class.__subclasses__`.
1936+
1937+
.. versionchanged:: 3.12
19321938

1933-
List of weak references to subclasses. Internal use only.
1939+
For some types, this field does not hold a valid :c:expr:`PyObject*`.
1940+
The type was changed to :c:expr:`void*` to indicate this.
19341941

19351942
**Inheritance:**
19361943

‎Doc/c-api/unicode.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,6 @@ APIs:
477477
| | | :c:func:`PyObject_Repr`. |
478478
+-------------------+---------------------+----------------------------------+
479479
480-
An unrecognized format character causes all the rest of the format string to be
481-
copied as-is to the result string, and any extra arguments discarded.
482-
483480
.. note::
484481
The width formatter unit is number of characters rather than bytes.
485482
The precision formatter unit is number of bytes for ``"%s"`` and
@@ -500,6 +497,11 @@ APIs:
500497
Support width and precision formatter for ``"%s"``, ``"%A"``, ``"%U"``,
501498
``"%V"``, ``"%S"``, ``"%R"`` added.
502499
500+
.. versionchanged:: 3.12
501+
An unrecognized format character now sets a :exc:`SystemError`.
502+
In previous versions it caused all the rest of the format string to be
503+
copied as-is to the result string, and any extra arguments discarded.
504+
503505
504506
.. c:function:: PyObject* PyUnicode_FromFormatV(const char *format, va_list vargs)
505507

‎Doc/conf.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979
'root_include_title': False # We use the version switcher instead.
8080
}
8181

82+
# Override stylesheet fingerprinting for Windows CHM htmlhelp to fix GH-91207
83+
# https://github.com/python/cpython/issues/91207
84+
if any('htmlhelp' in arg for arg in sys.argv):
85+
html_style = 'pydoctheme.css'
86+
print("\nWARNING: Windows CHM Help is no longer supported.")
87+
print("It may be removed in the future\n")
88+
8289
# Short title used e.g. for <title> HTML tags.
8390
html_short_title = '%s Documentation' % release
8491

‎Doc/data/stable_abi.dat‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Doc/extending/index.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Recommended third party tools
2727

2828
This guide only covers the basic tools for creating extensions provided
2929
as part of this version of CPython. Third party tools like
30-
`Cython <http://cython.org/>`_, `cffi <https://cffi.readthedocs.io>`_,
31-
`SWIG <http://www.swig.org>`_ and `Numba <https://numba.pydata.org/>`_
30+
`Cython <https://cython.org/>`_, `cffi <https://cffi.readthedocs.io>`_,
31+
`SWIG <https://www.swig.org>`_ and `Numba <https://numba.pydata.org/>`_
3232
offer both simpler and more sophisticated approaches to creating C and C++
3333
extensions for Python.
3434

0 commit comments

Comments
 (0)