Skip to content

Commit 966291c

Browse files
Merge remote-tracking branch 'origin/main' into pythongh-94906
2 parents 71e9d20 + 4a7f5a5 commit 966291c

File tree

446 files changed

+19231
-5717
lines changed

Some content is hidden

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

446 files changed

+19231
-5717
lines changed

.github/CONTRIBUTING.rst

+4-4
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

+2-2
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

+9
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

+25
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

+18
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

+36-29
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

+5-3
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

+7
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

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/extending/index.rst

+2-2
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

Doc/faq/design.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ is exactly the same type of object that a lambda expression yields) is assigned!
321321
Can Python be compiled to machine code, C or some other language?
322322
-----------------------------------------------------------------
323323

324-
`Cython <http://cython.org/>`_ compiles a modified version of Python with
325-
optional annotations into C extensions. `Nuitka <http://www.nuitka.net/>`_ is
324+
`Cython <https://cython.org/>`_ compiles a modified version of Python with
325+
optional annotations into C extensions. `Nuitka <https://www.nuitka.net/>`_ is
326326
an up-and-coming compiler of Python into C++ code, aiming to support the full
327327
Python language.
328328

@@ -338,8 +338,8 @@ cycles and deletes the objects involved. The :mod:`gc` module provides functions
338338
to perform a garbage collection, obtain debugging statistics, and tune the
339339
collector's parameters.
340340

341-
Other implementations (such as `Jython <http://www.jython.org>`_ or
342-
`PyPy <http://www.pypy.org>`_), however, can rely on a different mechanism
341+
Other implementations (such as `Jython <https://www.jython.org>`_ or
342+
`PyPy <https://www.pypy.org>`_), however, can rely on a different mechanism
343343
such as a full-blown garbage collector. This difference can cause some
344344
subtle porting problems if your Python code depends on the behavior of the
345345
reference counting implementation.

Doc/faq/extending.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ on what you're trying to do.
4141

4242
.. XXX make sure these all work
4343
44-
`Cython <http://cython.org>`_ and its relative `Pyrex
44+
`Cython <https://cython.org>`_ and its relative `Pyrex
4545
<https://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/>`_ are compilers
4646
that accept a slightly modified form of Python and generate the corresponding
4747
C code. Cython and Pyrex make it possible to write an extension without having
4848
to learn Python's C API.
4949

5050
If you need to interface to some C or C++ library for which no Python extension
5151
currently exists, you can try wrapping the library's data types and functions
52-
with a tool such as `SWIG <http://www.swig.org>`_. `SIP
52+
with a tool such as `SWIG <https://www.swig.org>`_. `SIP
5353
<https://riverbankcomputing.com/software/sip/intro>`__, `CXX
5454
<http://cxx.sourceforge.net/>`_ `Boost
55-
<http://www.boost.org/libs/python/doc/index.html>`_, or `Weave
55+
<https://www.boost.org/libs/python/doc/index.html>`_, or `Weave
5656
<https://github.com/scipy/weave>`_ are also
5757
alternatives for wrapping C++ libraries.
5858

@@ -286,6 +286,6 @@ Can I create an object class with some methods implemented in C and others in Py
286286
Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`,
287287
:class:`dict`, etc.
288288

289-
The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html)
289+
The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index.html)
290290
provides a way of doing this from C++ (i.e. you can inherit from an extension
291291
class written in C++ using the BPL).

Doc/faq/general.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ different companies and organizations.
330330

331331
High-profile Python projects include `the Mailman mailing list manager
332332
<http://www.list.org>`_ and `the Zope application server
333-
<http://www.zope.org>`_. Several Linux distributions, most notably `Red Hat
333+
<https://www.zope.dev>`_. Several Linux distributions, most notably `Red Hat
334334
<https://www.redhat.com>`_, have written part or all of their installer and
335335
system administration software in Python. Companies that use Python internally
336336
include Google, Yahoo, and Lucasfilm Ltd.

Doc/faq/programming.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ The following packages can help with the creation of console and GUI
9595
executables:
9696

9797
* `Nuitka <https://nuitka.net/>`_ (Cross-platform)
98-
* `PyInstaller <http://www.pyinstaller.org/>`_ (Cross-platform)
98+
* `PyInstaller <https://pyinstaller.org/>`_ (Cross-platform)
9999
* `PyOxidizer <https://pyoxidizer.readthedocs.io/en/stable/>`_ (Cross-platform)
100100
* `cx_Freeze <https://marcelotduarte.github.io/cx_Freeze/>`_ (Cross-platform)
101101
* `py2app <https://github.com/ronaldoussoren/py2app>`_ (macOS only)
@@ -1066,7 +1066,7 @@ performance levels:
10661066
detrimental to readability).
10671067

10681068
If you have reached the limit of what pure Python can allow, there are tools
1069-
to take you further away. For example, `Cython <http://cython.org>`_ can
1069+
to take you further away. For example, `Cython <https://cython.org>`_ can
10701070
compile a slightly modified version of Python code into a C extension, and
10711071
can be used on many different platforms. Cython can take advantage of
10721072
compilation (and optional type annotations) to make your code significantly

Doc/glossary.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,9 @@ Glossary
566566
from their :func:`id`.
567567

568568
IDLE
569-
An Integrated Development Environment for Python. IDLE is a basic editor
570-
and interpreter environment which ships with the standard distribution of
571-
Python.
569+
An Integrated Development and Learning Environment for Python.
570+
:ref:`idle` is a basic editor and interpreter environment
571+
which ships with the standard distribution of Python.
572572

573573
immutable
574574
An object with a fixed value. Immutable objects include numbers, strings and

0 commit comments

Comments
 (0)