Skip to content

Commit

Permalink
Merge branch 'main' into bpo_45113_3
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
shihai1991 committed Oct 21, 2021
2 parents 735ffb0 + 311910b commit 9d162ef
Show file tree
Hide file tree
Showing 1,124 changed files with 16,469 additions and 7,509 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ jobs:
- name: Check limited ABI symbols
run: make check-limited-abi
- name: Check Autoconf version 2.69
run: grep "Generated by GNU Autoconf 2.69" configure
run: |
grep "Generated by GNU Autoconf 2.69" configure
grep "PKG_PROG_PKG_CONFIG" aclocal.m4
build_win32:
name: 'Windows (x86)'
Expand Down Expand Up @@ -126,8 +128,12 @@ jobs:
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v2
- name: Prepare homebrew environment variables
run: |
echo "LDFLAGS=-L$(brew --prefix tcl-tk)/lib" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@1.1)/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
- name: Configure CPython
run: ./configure --with-pydebug --with-openssl=/usr/local/opt/openssl --prefix=/opt/python-dev
run: ./configure --with-pydebug --prefix=/opt/python-dev
- name: Build CPython
run: make -j4
- name: Display build info
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/call.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Object Calling API
Various functions are available for calling a Python object.
Each converts its arguments to a convention supported by the called object –
either *tp_call* or vectorcall.
In order to do as litle conversion as possible, pick one that best fits
In order to do as little conversion as possible, pick one that best fits
the format of data you have available.
The following table summarizes the available functions;
Expand Down
24 changes: 24 additions & 0 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,26 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
.. versionadded:: 3.9
.. c:function:: void PyThreadState_EnterTracing(PyThreadState *tstate)
Suspend tracing and profiling in the Python thread state *tstate*.
Resume them using the :c:func:`PyThreadState_LeaveTracing` function.
.. versionadded:: 3.11
.. c:function:: void PyThreadState_LeaveTracing(PyThreadState *tstate)
Resume tracing and profiling in the Python thread state *tstate* suspended
by the :c:func:`PyThreadState_EnterTracing` function.
See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile`
functions.
.. versionadded:: 3.11
.. c:function:: PyInterpreterState* PyInterpreterState_Get(void)
Get the current interpreter.
Expand Down Expand Up @@ -1623,6 +1643,8 @@ Python-level trace functions in previous versions.
profile function is called for all monitored events except :const:`PyTrace_LINE`
:const:`PyTrace_OPCODE` and :const:`PyTrace_EXCEPTION`.
See also the :func:`sys.setprofile` function.
The caller must hold the :term:`GIL`.
Expand All @@ -1635,6 +1657,8 @@ Python-level trace functions in previous versions.
will not receive :const:`PyTrace_C_CALL`, :const:`PyTrace_C_EXCEPTION` or
:const:`PyTrace_C_RETURN` as a value for the *what* parameter.
See also the :func:`sys.settrace` function.
The caller must hold the :term:`GIL`.
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ There are two kinds of configuration:
* The :ref:`Isolated Configuration <init-isolated-conf>` can be used to embed
Python into an application. It isolates Python from the system. For example,
environments variables are ignored, the LC_CTYPE locale is left unchanged and
no signal handler is registred.
no signal handler is registered.

The :c:func:`Py_RunMain` function can be used to write a customized Python
program.
Expand Down Expand Up @@ -706,7 +706,7 @@ PyConfig
* Otherwise, use the :term:`locale encoding`:
``nl_langinfo(CODESET)`` result.
At Python statup, the encoding name is normalized to the Python codec
At Python startup, the encoding name is normalized to the Python codec
name. For example, ``"ANSI_X3.4-1968"`` is replaced with ``"ascii"``.
See also the :c:member:`~PyConfig.filesystem_errors` member.
Expand Down
1 change: 1 addition & 0 deletions Doc/data/stable_abi.dat
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ function,PyStructSequence_GetItem,3.2,
function,PyStructSequence_New,3.2,
function,PyStructSequence_NewType,3.2,
function,PyStructSequence_SetItem,3.2,
var,PyStructSequence_UnnamedField,3.11,
var,PySuper_Type,3.2,
function,PySys_AddWarnOption,3.2,
function,PySys_AddWarnOptionUnicode,3.2,
Expand Down
8 changes: 4 additions & 4 deletions Doc/distributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ installing other Python projects, refer to the
Key terms
=========

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

* `Project structure`_
* `Building and packaging the project`_
* `Uploading the project to the Python Packaging Index`_
* `Uploading the project to the Python Package Index`_
* `The .pypirc file`_

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

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

* check the Python Packaging Index to see if the name is already in use
* check the Python Package Index to see if the name is already in use
* check popular hosting sites like GitHub, Bitbucket, etc to see if there
is already a project with that name
* check what comes up in a web search for the name you're considering
Expand Down
2 changes: 1 addition & 1 deletion Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ Why don't generators support the with statement?
For technical reasons, a generator used directly as a context manager
would not work correctly. When, as is most common, a generator is used as
an iterator run to completion, no closing is needed. When it is, wrap
it as "contextlib.closing(generator)" in the 'with' statment.
it as "contextlib.closing(generator)" in the 'with' statement.


Why are colons required for the if/while/def/class statements?
Expand Down
3 changes: 0 additions & 3 deletions Doc/faq/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ complete example using the GNU readline library (you may want to ignore

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <object.h>
#include <compile.h>
#include <eval.h>

int main (int argc, char* argv[])
{
Expand Down
21 changes: 21 additions & 0 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,27 @@ ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug waiting to
bite.


How do I get int literal attribute instead of SyntaxError?
----------------------------------------------------------

Trying to lookup an ``int`` literal attribute in the normal manner gives
a syntax error because the period is seen as a decimal point::

>>> 1.__class__
File "<stdin>", line 1
1.__class__
^
SyntaxError: invalid decimal literal

The solution is to separate the literal from the period
with either a space or parentheses.

>>> 1 .__class__
<class 'int'>
>>> (1).__class__
<class 'int'>


How do I convert a string to a number?
--------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Doc/faq/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Embedding the Python interpreter in a Windows app can be summarized as follows:

.. code-block:: c
#include "python.h"
#include <Python.h>
...
Py_Initialize(); // Initialize Python.
initmyAppc(); // Initialize (import) the helper class.
Expand Down
3 changes: 0 additions & 3 deletions Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,6 @@ expression. Currently the following are explicitly supported:
* Simple symbolic constants like ``sys.maxsize``, which must
start with the name of the module

In case you're curious, this is implemented in ``from_builtin()``
in ``Lib/inspect.py``.

(In the future, this may need to get even more elaborate,
to allow full expressions like ``CONSTANT - 1``.)

Expand Down
3 changes: 2 additions & 1 deletion Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,8 @@ and raise an error if the two do not match::
_Private__names
"""""""""""""""

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

.. versionchanged:: 3.10

Expand Down
9 changes: 4 additions & 5 deletions Doc/howto/functional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ output must only depend on its input.

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

Python programs written in functional style usually won't go to the extreme of
avoiding all I/O or all assignments; instead, they'll provide a
Expand Down
4 changes: 2 additions & 2 deletions Doc/includes/sqlite3/text_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
con = sqlite3.connect(":memory:")
cur = con.cursor()

AUSTRIA = "\xd6sterreich"
AUSTRIA = "Österreich"

# by default, rows are returned as Unicode
# by default, rows are returned as str
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()
assert row[0] == AUSTRIA
Expand Down
6 changes: 3 additions & 3 deletions Doc/installing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Key terms
``venv``. It allows virtual environments to be used on versions of
Python prior to 3.4, which either don't provide ``venv`` at all, or
aren't able to automatically install ``pip`` into created environments.
* The `Python Packaging Index <https://pypi.org>`__ is a public
* The `Python Package Index <https://pypi.org>`__ is a public
repository of open source licensed packages made available for use by
other Python users.
* the `Python Packaging Authority
Expand Down Expand Up @@ -78,7 +78,7 @@ The standard packaging tools are all designed to be used from the command
line.

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

python -m pip install SomePackage

Expand Down Expand Up @@ -226,7 +226,7 @@ the installation process.

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

Expand Down
5 changes: 5 additions & 0 deletions Doc/library/2to3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ contains a rich set of fixers that will handle almost all code. 2to3 supporting
library :mod:`lib2to3` is, however, a flexible and generic library, so it is
possible to write your own fixers for 2to3.

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

.. _2to3-using:

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ Anything with more interesting error-handling or resource management should be
done downstream after the arguments are parsed.

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

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ Pattern matching
the pattern matches the subject.

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

.. doctest::

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

.. warning::
Note that succesfully parsing souce code into an AST object doesn't
Note that successfully parsing source code into an AST object doesn't
guarantee that the source code provided is valid Python code that can
be executed as the compilation step can raise further :exc:`SyntaxError`
exceptions. For instance, the source ``return 42`` generates a valid
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ When the debug mode is enabled:
* The execution time of the I/O selector is logged if it takes too long to
perform an I/O operation.

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

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ All event loops on Windows do not support the following methods:
methods are not supported.

The resolution of the monotonic clock on Windows is usually around 15.6
msec. The best resolution is 0.5 msec. The resolution depends on the
milliseconds. The best resolution is 0.5 milliseconds. The resolution depends on the
hardware (availability of `HPET
<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
Windows configuration.
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/asyncio-stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ TCP echo server using the :func:`asyncio.start_server` function::
server = await asyncio.start_server(
handle_echo, '127.0.0.1', 8888)

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

async with server:
await server.serve_forever()
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/base64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ The modern interface provides:
This version does not allow the digit 0 (zero) to the letter O (oh) and digit
1 (one) to either the letter I (eye) or letter L (el) mappings, all these
characters are included in the Extended Hex Alphabet and are not
interchangable.
interchangeable.

.. versionadded:: 3.10

Expand Down
3 changes: 3 additions & 0 deletions Doc/library/collections.abc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ example, knowing that a class supplies ``__getitem__``, ``__len__``, and
``__iter__`` is insufficient for distinguishing a :class:`Sequence` from
a :class:`Mapping`.

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

.. _collections-abstract-base-classes:

Expand Down
21 changes: 19 additions & 2 deletions Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,23 @@ Functions and classes provided:
.. versionadded:: 3.5


.. function:: chdir(path)

Non parallel-safe context manager to change the current working directory.
As this changes a global state, the working directory, it is not suitable
for use in most threaded or async contexts. It is also not suitable for most
non-linear code execution, like generators, where the program execution is
temporarily relinquished -- unless explicitely desired, you should not yield
when this context manager is active.

This is a simple wrapper around :func:`~os.chdir`, it changes the current
working directory upon entering and restores the old one on exit.

This context manager is :ref:`reentrant <reentrant-cms>`.

.. versionadded:: 3.11


.. class:: ContextDecorator()

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

:class:`threading.RLock` is an example of a reentrant context manager, as are
:func:`suppress` and :func:`redirect_stdout`. Here's a very simple example of
reentrant use::
:func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a very
simple example of reentrant use::

>>> from contextlib import redirect_stdout
>>> from io import StringIO
Expand Down
Loading

0 comments on commit 9d162ef

Please sign in to comment.