Skip to content

Commit 9d162ef

Browse files
committed
Merge branch 'main' into bpo_45113_3
* main: (263 commits) bpo-45521: Fix a bug in the obmalloc radix tree code. (pythonGH-29051) bpo-45522: Allow to disable freelists on build time (pythonGH-29056) bpo-34451: Document prompt and output toggle feature in html tutorial (pythonGH-27105) bpo-44019: Add operator.call() to __all__ for the operator module (pythonGH-29110) bpo-45315: PyType_FromSpec: Copy spec->name and have the type own the memory for its name (pythonGH-29103) bpo-44220: Export PyStructSequence_UnnamedField in the limited API (pythonGH-26331) bpo-44174: [Enum] add reference to name mangling (pythonGH-29116) bpo-45548: add some missing entries to `Modules/Setup` (pythonGH-29115) bpo-35673: Add a public alias for namespace package __loader__ attribute (python#29049) bpo-45192: Fix a bug that infers the type of an os.PathLike[bytes] object as str (pythonGH-28323) bpo-45527: Don't count cache hits, just misses. (pythonGH-29092) bpo-45320: Remove long-deprecated inspect methods (pythonGH-28618) bpo-41374: Remove obsolete exclusion of netinet/tcp.h on Cygwin (pythonGH-21649) bpo-45532: Replace 'default' with 'main' as default in sys.version (pythonGH-29100) bpo-45464: [doc] Explain that subclassing multiple exceptions is fragile (pythonGH-29094) Cleanup a couple of comments left on PR 28775 post-merge. (pythonGH-29079) bpo-45536: Check OpenSSL APIs in configure (pythonGH-29088) Add PEPs 593 & 647 to list of PEPs at top of typing docs (pythonGH-29097) Add a comment about how to fix bogus test_host_resolution_bad_address failures (python#29085) bpo-44525: Specialize simple Python calls. (pythonGH-29033) ...
2 parents 735ffb0 + 311910b commit 9d162ef

File tree

1,124 files changed

+16469
-7509
lines changed

Some content is hidden

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

1,124 files changed

+16469
-7509
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ jobs:
8585
- name: Check limited ABI symbols
8686
run: make check-limited-abi
8787
- name: Check Autoconf version 2.69
88-
run: grep "Generated by GNU Autoconf 2.69" configure
88+
run: |
89+
grep "Generated by GNU Autoconf 2.69" configure
90+
grep "PKG_PROG_PKG_CONFIG" aclocal.m4
8991
9092
build_win32:
9193
name: 'Windows (x86)'
@@ -126,8 +128,12 @@ jobs:
126128
PYTHONSTRICTEXTENSIONBUILD: 1
127129
steps:
128130
- uses: actions/checkout@v2
131+
- name: Prepare homebrew environment variables
132+
run: |
133+
echo "LDFLAGS=-L$(brew --prefix tcl-tk)/lib" >> $GITHUB_ENV
134+
echo "PKG_CONFIG_PATH=$(brew --prefix [email protected])/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
129135
- name: Configure CPython
130-
run: ./configure --with-pydebug --with-openssl=/usr/local/opt/openssl --prefix=/opt/python-dev
136+
run: ./configure --with-pydebug --prefix=/opt/python-dev
131137
- name: Build CPython
132138
run: make -j4
133139
- name: Display build info

Doc/c-api/call.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Object Calling API
185185
Various functions are available for calling a Python object.
186186
Each converts its arguments to a convention supported by the called object –
187187
either *tp_call* or vectorcall.
188-
In order to do as litle conversion as possible, pick one that best fits
188+
In order to do as little conversion as possible, pick one that best fits
189189
the format of data you have available.
190190
191191
The following table summarizes the available functions;

Doc/c-api/init.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,26 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
11731173
.. versionadded:: 3.9
11741174
11751175
1176+
.. c:function:: void PyThreadState_EnterTracing(PyThreadState *tstate)
1177+
1178+
Suspend tracing and profiling in the Python thread state *tstate*.
1179+
1180+
Resume them using the :c:func:`PyThreadState_LeaveTracing` function.
1181+
1182+
.. versionadded:: 3.11
1183+
1184+
1185+
.. c:function:: void PyThreadState_LeaveTracing(PyThreadState *tstate)
1186+
1187+
Resume tracing and profiling in the Python thread state *tstate* suspended
1188+
by the :c:func:`PyThreadState_EnterTracing` function.
1189+
1190+
See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile`
1191+
functions.
1192+
1193+
.. versionadded:: 3.11
1194+
1195+
11761196
.. c:function:: PyInterpreterState* PyInterpreterState_Get(void)
11771197
11781198
Get the current interpreter.
@@ -1623,6 +1643,8 @@ Python-level trace functions in previous versions.
16231643
profile function is called for all monitored events except :const:`PyTrace_LINE`
16241644
:const:`PyTrace_OPCODE` and :const:`PyTrace_EXCEPTION`.
16251645
1646+
See also the :func:`sys.setprofile` function.
1647+
16261648
The caller must hold the :term:`GIL`.
16271649
16281650
@@ -1635,6 +1657,8 @@ Python-level trace functions in previous versions.
16351657
will not receive :const:`PyTrace_C_CALL`, :const:`PyTrace_C_EXCEPTION` or
16361658
:const:`PyTrace_C_RETURN` as a value for the *what* parameter.
16371659
1660+
See also the :func:`sys.settrace` function.
1661+
16381662
The caller must hold the :term:`GIL`.
16391663
16401664

Doc/c-api/init_config.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ There are two kinds of configuration:
2222
* The :ref:`Isolated Configuration <init-isolated-conf>` can be used to embed
2323
Python into an application. It isolates Python from the system. For example,
2424
environments variables are ignored, the LC_CTYPE locale is left unchanged and
25-
no signal handler is registred.
25+
no signal handler is registered.
2626

2727
The :c:func:`Py_RunMain` function can be used to write a customized Python
2828
program.
@@ -706,7 +706,7 @@ PyConfig
706706
* Otherwise, use the :term:`locale encoding`:
707707
``nl_langinfo(CODESET)`` result.
708708
709-
At Python statup, the encoding name is normalized to the Python codec
709+
At Python startup, the encoding name is normalized to the Python codec
710710
name. For example, ``"ANSI_X3.4-1968"`` is replaced with ``"ascii"``.
711711
712712
See also the :c:member:`~PyConfig.filesystem_errors` member.

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ function,PyStructSequence_GetItem,3.2,
570570
function,PyStructSequence_New,3.2,
571571
function,PyStructSequence_NewType,3.2,
572572
function,PyStructSequence_SetItem,3.2,
573+
var,PyStructSequence_UnnamedField,3.11,
573574
var,PySuper_Type,3.2,
574575
function,PySys_AddWarnOption,3.2,
575576
function,PySys_AddWarnOptionUnicode,3.2,

Doc/distributing/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ installing other Python projects, refer to the
3131
Key terms
3232
=========
3333

34-
* the `Python Packaging Index <https://pypi.org>`__ is a public
34+
* the `Python Package Index <https://pypi.org>`__ is a public
3535
repository of open source licensed packages made available for use by
3636
other Python users
3737
* the `Python Packaging Authority
@@ -127,14 +127,14 @@ involved in creating and publishing a project:
127127

128128
* `Project structure`_
129129
* `Building and packaging the project`_
130-
* `Uploading the project to the Python Packaging Index`_
130+
* `Uploading the project to the Python Package Index`_
131131
* `The .pypirc file`_
132132

133133
.. _Project structure: \
134134
https://packaging.python.org/tutorials/packaging-projects/#packaging-python-projects
135135
.. _Building and packaging the project: \
136136
https://packaging.python.org/tutorials/packaging-projects/#creating-the-package-files
137-
.. _Uploading the project to the Python Packaging Index: \
137+
.. _Uploading the project to the Python Package Index: \
138138
https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives
139139
.. _The .pypirc file: \
140140
https://packaging.python.org/specifications/pypirc/
@@ -150,7 +150,7 @@ These are quick answers or links for some common tasks.
150150

151151
This isn't an easy topic, but here are a few tips:
152152

153-
* check the Python Packaging Index to see if the name is already in use
153+
* check the Python Package Index to see if the name is already in use
154154
* check popular hosting sites like GitHub, Bitbucket, etc to see if there
155155
is already a project with that name
156156
* check what comes up in a web search for the name you're considering

Doc/faq/design.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ Why don't generators support the with statement?
714714
For technical reasons, a generator used directly as a context manager
715715
would not work correctly. When, as is most common, a generator is used as
716716
an iterator run to completion, no closing is needed. When it is, wrap
717-
it as "contextlib.closing(generator)" in the 'with' statment.
717+
it as "contextlib.closing(generator)" in the 'with' statement.
718718

719719

720720
Why are colons required for the if/while/def/class statements?

Doc/faq/extending.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ complete example using the GNU readline library (you may want to ignore
290290

291291
#define PY_SSIZE_T_CLEAN
292292
#include <Python.h>
293-
#include <object.h>
294-
#include <compile.h>
295-
#include <eval.h>
296293

297294
int main (int argc, char* argv[])
298295
{

Doc/faq/programming.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,27 @@ ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug waiting to
836836
bite.
837837

838838

839+
How do I get int literal attribute instead of SyntaxError?
840+
----------------------------------------------------------
841+
842+
Trying to lookup an ``int`` literal attribute in the normal manner gives
843+
a syntax error because the period is seen as a decimal point::
844+
845+
>>> 1.__class__
846+
File "<stdin>", line 1
847+
1.__class__
848+
^
849+
SyntaxError: invalid decimal literal
850+
851+
The solution is to separate the literal from the period
852+
with either a space or parentheses.
853+
854+
>>> 1 .__class__
855+
<class 'int'>
856+
>>> (1).__class__
857+
<class 'int'>
858+
859+
839860
How do I convert a string to a number?
840861
--------------------------------------
841862

Doc/faq/windows.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Embedding the Python interpreter in a Windows app can be summarized as follows:
212212

213213
.. code-block:: c
214214
215-
#include "python.h"
215+
#include <Python.h>
216216
...
217217
Py_Initialize(); // Initialize Python.
218218
initmyAppc(); // Initialize (import) the helper class.

Doc/howto/clinic.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,6 @@ expression. Currently the following are explicitly supported:
567567
* Simple symbolic constants like ``sys.maxsize``, which must
568568
start with the name of the module
569569

570-
In case you're curious, this is implemented in ``from_builtin()``
571-
in ``Lib/inspect.py``.
572-
573570
(In the future, this may need to get even more elaborate,
574571
to allow full expressions like ``CONSTANT - 1``.)
575572

Doc/howto/enum.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ and raise an error if the two do not match::
936936
_Private__names
937937
"""""""""""""""
938938

939-
Private names are not converted to enum members, but remain normal attributes.
939+
:ref:`Private names <private-name-mangling>` are not converted to enum members,
940+
but remain normal attributes.
940941

941942
.. versionchanged:: 3.10
942943

Doc/howto/functional.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ output must only depend on its input.
6565

6666
Some languages are very strict about purity and don't even have assignment
6767
statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all
68-
side effects. Printing to the screen or writing to a disk file are side
69-
effects, for example. For example, in Python a call to the :func:`print` or
70-
:func:`time.sleep` function both return no useful value; they're only called for
71-
their side effects of sending some text to the screen or pausing execution for a
72-
second.
68+
side effects, such as printing to the screen or writing to a disk file. Another
69+
example is a call to the :func:`print` or :func:`time.sleep` function, neither
70+
of which returns a useful value. Both are called only for their side effects
71+
of sending some text to the screen or pausing execution for a second.
7372

7473
Python programs written in functional style usually won't go to the extreme of
7574
avoiding all I/O or all assignments; instead, they'll provide a

Doc/includes/sqlite3/text_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
con = sqlite3.connect(":memory:")
44
cur = con.cursor()
55

6-
AUSTRIA = "\xd6sterreich"
6+
AUSTRIA = "Österreich"
77

8-
# by default, rows are returned as Unicode
8+
# by default, rows are returned as str
99
cur.execute("select ?", (AUSTRIA,))
1010
row = cur.fetchone()
1111
assert row[0] == AUSTRIA

Doc/installing/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Key terms
4444
``venv``. It allows virtual environments to be used on versions of
4545
Python prior to 3.4, which either don't provide ``venv`` at all, or
4646
aren't able to automatically install ``pip`` into created environments.
47-
* The `Python Packaging Index <https://pypi.org>`__ is a public
47+
* The `Python Package Index <https://pypi.org>`__ is a public
4848
repository of open source licensed packages made available for use by
4949
other Python users.
5050
* the `Python Packaging Authority
@@ -78,7 +78,7 @@ The standard packaging tools are all designed to be used from the command
7878
line.
7979

8080
The following command will install the latest version of a module and its
81-
dependencies from the Python Packaging Index::
81+
dependencies from the Python Package Index::
8282

8383
python -m pip install SomePackage
8484

@@ -226,7 +226,7 @@ the installation process.
226226

227227
With the introduction of support for the binary ``wheel`` format, and the
228228
ability to publish wheels for at least Windows and macOS through the
229-
Python Packaging Index, this problem is expected to diminish over time,
229+
Python Package Index, this problem is expected to diminish over time,
230230
as users are more regularly able to install pre-built extensions rather
231231
than needing to build them themselves.
232232

Doc/library/2to3.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ contains a rich set of fixers that will handle almost all code. 2to3 supporting
1111
library :mod:`lib2to3` is, however, a flexible and generic library, so it is
1212
possible to write your own fixers for 2to3.
1313

14+
.. deprecated-removed:: 3.11 3.13
15+
The ``lib2to3`` module was marked pending for deprecation in Python 3.9
16+
(raising :exc:`PendingDeprecationWarning` on import) and fully deprecated
17+
in Python 3.11 (raising :exc:`DeprecationWarning`). The ``2to3`` tool is
18+
part of that. It will be removed in Python 3.13.
1419

1520
.. _2to3-using:
1621

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ Anything with more interesting error-handling or resource management should be
11091109
done downstream after the arguments are parsed.
11101110

11111111
For example, JSON or YAML conversions have complex error cases that require
1112-
better reporting than can be given by the ``type`` keyword. An
1112+
better reporting than can be given by the ``type`` keyword. A
11131113
:exc:`~json.JSONDecodeError` would not be well formatted and a
11141114
:exc:`FileNotFound` exception would not be handled at all.
11151115

Doc/library/ast.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ Pattern matching
12661266
the pattern matches the subject.
12671267

12681268
``body`` contains a list of nodes to execute if the pattern matches and
1269-
the result of evaluating the guard expression is truthy.
1269+
the result of evaluating the guard expression is true.
12701270

12711271
.. doctest::
12721272

@@ -1920,7 +1920,7 @@ and classes for traversing abstract syntax trees:
19201920
If source contains a null character ('\0'), :exc:`ValueError` is raised.
19211921

19221922
.. warning::
1923-
Note that succesfully parsing souce code into an AST object doesn't
1923+
Note that successfully parsing source code into an AST object doesn't
19241924
guarantee that the source code provided is valid Python code that can
19251925
be executed as the compilation step can raise further :exc:`SyntaxError`
19261926
exceptions. For instance, the source ``return 42`` generates a valid

Doc/library/asyncio-dev.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ When the debug mode is enabled:
5757
* The execution time of the I/O selector is logged if it takes too long to
5858
perform an I/O operation.
5959

60-
* Callbacks taking longer than 100ms are logged. The
60+
* Callbacks taking longer than 100 milliseconds are logged. The
6161
:attr:`loop.slow_callback_duration` attribute can be used to set the
6262
minimum execution duration in seconds that is considered "slow".
6363

Doc/library/asyncio-platforms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ All event loops on Windows do not support the following methods:
6363
methods are not supported.
6464

6565
The resolution of the monotonic clock on Windows is usually around 15.6
66-
msec. The best resolution is 0.5 msec. The resolution depends on the
66+
milliseconds. The best resolution is 0.5 milliseconds. The resolution depends on the
6767
hardware (availability of `HPET
6868
<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
6969
Windows configuration.

Doc/library/asyncio-stream.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ TCP echo server using the :func:`asyncio.start_server` function::
395395
server = await asyncio.start_server(
396396
handle_echo, '127.0.0.1', 8888)
397397

398-
addr = server.sockets[0].getsockname()
399-
print(f'Serving on {addr}')
398+
addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets)
399+
print(f'Serving on {addrs}')
400400

401401
async with server:
402402
await server.serve_forever()

Doc/library/base64.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ The modern interface provides:
154154
This version does not allow the digit 0 (zero) to the letter O (oh) and digit
155155
1 (one) to either the letter I (eye) or letter L (el) mappings, all these
156156
characters are included in the Extended Hex Alphabet and are not
157-
interchangable.
157+
interchangeable.
158158

159159
.. versionadded:: 3.10
160160

Doc/library/collections.abc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ example, knowing that a class supplies ``__getitem__``, ``__len__``, and
104104
``__iter__`` is insufficient for distinguishing a :class:`Sequence` from
105105
a :class:`Mapping`.
106106

107+
.. versionadded:: 3.9
108+
These abstract classes now support ``[]``. See :ref:`types-genericalias`
109+
and :pep:`585`.
107110

108111
.. _collections-abstract-base-classes:
109112

Doc/library/contextlib.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,23 @@ Functions and classes provided:
353353
.. versionadded:: 3.5
354354

355355

356+
.. function:: chdir(path)
357+
358+
Non parallel-safe context manager to change the current working directory.
359+
As this changes a global state, the working directory, it is not suitable
360+
for use in most threaded or async contexts. It is also not suitable for most
361+
non-linear code execution, like generators, where the program execution is
362+
temporarily relinquished -- unless explicitely desired, you should not yield
363+
when this context manager is active.
364+
365+
This is a simple wrapper around :func:`~os.chdir`, it changes the current
366+
working directory upon entering and restores the old one on exit.
367+
368+
This context manager is :ref:`reentrant <reentrant-cms>`.
369+
370+
.. versionadded:: 3.11
371+
372+
356373
.. class:: ContextDecorator()
357374

358375
A base class that enables a context manager to also be used as a decorator.
@@ -900,8 +917,8 @@ but may also be used *inside* a :keyword:`!with` statement that is already
900917
using the same context manager.
901918

902919
:class:`threading.RLock` is an example of a reentrant context manager, as are
903-
:func:`suppress` and :func:`redirect_stdout`. Here's a very simple example of
904-
reentrant use::
920+
:func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a very
921+
simple example of reentrant use::
905922

906923
>>> from contextlib import redirect_stdout
907924
>>> from io import StringIO

0 commit comments

Comments
 (0)