Skip to content

Commit 089cb17

Browse files
authored
Merge branch 'main' into login_tty
2 parents d30e66b + f42a06b commit 089cb17

File tree

284 files changed

+20770
-13695
lines changed

Some content is hidden

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

284 files changed

+20770
-13695
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ jobs:
9595
runs-on: windows-latest
9696
needs: check_source
9797
if: needs.check_source.outputs.run_tests == 'true'
98+
env:
99+
IncludeUwp: 'true'
98100
steps:
99101
- uses: actions/checkout@v2
100102
- name: Build CPython
@@ -109,6 +111,8 @@ jobs:
109111
runs-on: windows-latest
110112
needs: check_source
111113
if: needs.check_source.outputs.run_tests == 'true'
114+
env:
115+
IncludeUwp: 'true'
112116
steps:
113117
- uses: actions/checkout@v2
114118
- name: Register MSVC problem matcher
@@ -175,13 +179,28 @@ jobs:
175179
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
176180
- name: Configure ccache action
177181
uses: hendrikmuhs/ccache-action@v1
178-
- name: Configure CPython
179-
run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR
180-
- name: Build CPython
182+
- name: Setup directory envs for out-of-tree builds
183+
run: |
184+
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
185+
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
186+
- name: Create directories for read-only out-of-tree builds
187+
run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
188+
- name: Bind mount sources read-only
189+
run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
190+
- name: Configure CPython out-of-tree
191+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
192+
run: ../cpython-ro-srcdir/configure --with-pydebug --with-openssl=$OPENSSL_DIR
193+
- name: Build CPython out-of-tree
194+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
181195
run: make -j4
182196
- name: Display build info
197+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
183198
run: make pythoninfo
199+
- name: Remount sources writable for tests
200+
# some tests write to srcdir, lack of pyc files slows down testing
201+
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
184202
- name: Tests
203+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
185204
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
186205

187206
build_ubuntu_ssltests:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.so.*
1111
*.dylib
1212
*.dll
13+
*.wasm
1314
*.orig
1415
*.pyc
1516
*.pyd

Doc/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ suspicious:
117117
"or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
118118
"positives, append that file to tools/susp-ignored.csv."; \
119119
false; }
120+
@echo "⚠ make suspicious is deprecated and will be removed soon."
121+
@echo "⚠ Use:"
122+
@echo "⚠ make check"
123+
@echo "⚠ instead."
120124

121125
coverage: BUILDER = coverage
122126
coverage: build

Doc/c-api/exceptions.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ Querying the error indicator
482482
to an exception that was *already caught*, not to an exception that was
483483
freshly raised. This function steals the references of the arguments.
484484
To clear the exception state, pass ``NULL`` for all three arguments.
485-
For general rules about the three arguments, see :c:func:`PyErr_Restore`.
486485
487486
.. note::
488487
@@ -493,6 +492,12 @@ Querying the error indicator
493492
494493
.. versionadded:: 3.3
495494
495+
.. versionchanged:: 3.11
496+
The ``type`` and ``traceback`` arguments are no longer used and
497+
can be NULL. The interpreter now derives them from the exception
498+
instance (the ``value`` argument). The function still steals
499+
references of all three arguments.
500+
496501
497502
Signal Handling
498503
===============

Doc/c-api/init_config.rst

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ PyConfig
479479
480480
Fields which are already initialized are left unchanged.
481481
482+
Fields for :ref:`path configuration <init-path-config>` are no longer
483+
calculated or modified when calling this function, as of Python 3.11.
484+
482485
The :c:func:`PyConfig_Read` function only parses
483486
:c:member:`PyConfig.argv` arguments once: :c:member:`PyConfig.parse_argv`
484487
is set to ``2`` after arguments are parsed. Since Python arguments are
@@ -493,6 +496,12 @@ PyConfig
493496
parsed, and arguments are only parsed if
494497
:c:member:`PyConfig.parse_argv` equals ``1``.
495498
499+
.. versionchanged:: 3.11
500+
:c:func:`PyConfig_Read` no longer calculates all paths, and so fields
501+
listed under :ref:`Python Path Configuration <init-path-config>` may
502+
no longer be updated until :c:func:`Py_InitializeFromConfig` is
503+
called.
504+
496505
.. c:function:: void PyConfig_Clear(PyConfig *config)
497506
498507
Release configuration memory.
@@ -596,13 +605,16 @@ PyConfig
596605
597606
.. versionadded:: 3.10
598607
599-
.. c:member:: int no_debug_ranges
608+
.. c:member:: int code_debug_ranges
600609
601-
If equals to ``1``, disables the inclusion of the end line and column
610+
If equals to ``0``, disables the inclusion of the end line and column
602611
mappings in code objects. Also disables traceback printing carets to
603612
specific error locations.
604613
605-
Default: ``0``.
614+
Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable
615+
and by the :option:`-X no_debug_ranges <-X>` command line option.
616+
617+
Default: ``1``.
606618
607619
.. versionadded:: 3.11
608620
@@ -845,12 +857,19 @@ PyConfig
845857
846858
Default: value of the ``PLATLIBDIR`` macro which is set by the
847859
:option:`configure --with-platlibdir option <--with-platlibdir>`
848-
(default: ``"lib"``).
860+
(default: ``"lib"``, or ``"DLLs"`` on Windows).
849861
850862
Part of the :ref:`Python Path Configuration <init-path-config>` input.
851863
852864
.. versionadded:: 3.9
853865
866+
.. versionchanged:: 3.11
867+
This macro is now used on Windows to locate the standard
868+
library extension modules, typically under ``DLLs``. However,
869+
for compatibility, note that this value is ignored for any
870+
non-standard layouts, including in-tree builds and virtual
871+
environments.
872+
854873
.. c:member:: wchar_t* pythonpath_env
855874
856875
Module search paths (:data:`sys.path`) as a string separated by ``DELIM``
@@ -867,9 +886,9 @@ PyConfig
867886
868887
Module search paths: :data:`sys.path`.
869888
870-
If :c:member:`~PyConfig.module_search_paths_set` is equal to 0, the
871-
function calculating the :ref:`Python Path Configuration <init-path-config>`
872-
overrides the :c:member:`~PyConfig.module_search_paths` and sets
889+
If :c:member:`~PyConfig.module_search_paths_set` is equal to 0,
890+
:c:func:`Py_InitializeFromConfig` will replace
891+
:c:member:`~PyConfig.module_search_paths` and sets
873892
:c:member:`~PyConfig.module_search_paths_set` to ``1``.
874893
875894
Default: empty list (``module_search_paths``) and ``0``
@@ -941,16 +960,16 @@ PyConfig
941960
942961
.. c:member:: int pathconfig_warnings
943962
944-
On Unix, if non-zero, calculating the :ref:`Python Path Configuration
945-
<init-path-config>` can log warnings into ``stderr``. If equals to 0,
946-
suppress these warnings.
947-
948-
It has no effect on Windows.
963+
If non-zero, calculation of path configuration is allowed to log
964+
warnings into ``stderr``. If equals to 0, suppress these warnings.
949965
950966
Default: ``1`` in Python mode, ``0`` in isolated mode.
951967
952968
Part of the :ref:`Python Path Configuration <init-path-config>` input.
953969
970+
.. versionchanged:: 3.11
971+
Now also applies on Windows.
972+
954973
.. c:member:: wchar_t* prefix
955974
956975
The site-specific directory prefix where the platform independent Python
@@ -1302,10 +1321,9 @@ variables, command line arguments (:c:member:`PyConfig.argv` is not parsed)
13021321
and user site directory. The C standard streams (ex: ``stdout``) and the
13031322
LC_CTYPE locale are left unchanged. Signal handlers are not installed.
13041323
1305-
Configuration files are still used with this configuration. Set the
1306-
:ref:`Python Path Configuration <init-path-config>` ("output fields") to ignore these
1307-
configuration files and avoid the function computing the default path
1308-
configuration.
1324+
Configuration files are still used with this configuration to determine
1325+
paths that are unspecified. Ensure :c:member:`PyConfig.home` is specified
1326+
to avoid computing the default path configuration.
13091327
13101328
13111329
.. _init-python-config:

Doc/faq/library.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ Be sure to use the :mod:`threading` module and not the :mod:`_thread` module.
240240
The :mod:`threading` module builds convenient abstractions on top of the
241241
low-level primitives provided by the :mod:`_thread` module.
242242
243-
Aahz has a set of slides from his threading tutorial that are helpful; see
244-
http://www.pythoncraft.com/OSCON2001/.
245-
246243
247244
None of my threads seem to run: why?
248245
------------------------------------
@@ -614,9 +611,9 @@ use ``p.read(n)``.
614611
How do I access the serial (RS232) port?
615612
----------------------------------------
616613
617-
For Win32, POSIX (Linux, BSD, etc.), Jython:
614+
For Win32, OSX, Linux, BSD, Jython, IronPython:
618615
619-
http://pyserial.sourceforge.net
616+
https://pypi.org/project/pyserial/
620617
621618
For Unix, see a Usenet post by Mitch Chapman:
622619

Doc/faq/programming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ Jim Roskind suggests performing steps in the following order in each module:
20922092
* ``import`` statements
20932093
* active code (including globals that are initialized from imported values).
20942094

2095-
van Rossum doesn't like this approach much because the imports appear in a
2095+
Van Rossum doesn't like this approach much because the imports appear in a
20962096
strange place, but it does work.
20972097

20982098
Matthias Urlichs recommends restructuring your code so that the recursive import

Doc/howto/annotations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Manually Un-Stringizing Stringized Annotations
156156
require annotating with string values that specifically
157157
*can't* be evaluated. For example:
158158

159-
* :pep:`604` union types using `|`, before support for this
159+
* :pep:`604` union types using ``|``, before support for this
160160
was added to Python 3.10.
161161
* Definitions that aren't needed at runtime, only imported
162162
when :const:`typing.TYPE_CHECKING` is true.

Doc/howto/enum.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,11 +997,12 @@ Plain :class:`Enum` classes always evaluate as :data:`True`.
997997
"""""""""""""""""""""""""""""
998998

999999
If you give your enum subclass extra methods, like the `Planet`_
1000-
class below, those methods will show up in a :func:`dir` of the member,
1001-
but not of the class::
1000+
class below, those methods will show up in a :func:`dir` of the member and the
1001+
class. Attributes defined in an :func:`__init__` method will only show up in a
1002+
:func:`dir` of the member::
10021003

10031004
>>> dir(Planet)
1004-
['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__doc__', '__members__', '__module__']
1005+
['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__doc__', '__init__', '__members__', '__module__', 'surface_gravity']
10051006
>>> dir(Planet.EARTH)
10061007
['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', 'surface_gravity', 'value']
10071008

Doc/howto/logging-cookbook.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,17 @@ alternative there, as well as adapting the above script to use your alternative
541541
serialization.
542542

543543

544+
Running a logging socket listener in production
545+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
546+
547+
To run a logging listener in production, you may need to use a process-management tool
548+
such as `Supervisor <http://supervisord.org/>`_. `Here
549+
<https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b>`_ is a Gist which
550+
provides the bare-bones files to run the above functionality using Supervisor: you
551+
will need to change the `/path/to/` parts in the Gist to reflect the actual paths you
552+
want to use.
553+
554+
544555
.. _context-info:
545556

546557
Adding contextual information to your logging output
@@ -982,6 +993,17 @@ to this (remembering to first import :mod:`concurrent.futures`)::
982993
for i in range(10):
983994
executor.submit(worker_process, queue, worker_configurer)
984995

996+
Deploying Web applications using Gunicorn and uWSGI
997+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
998+
999+
When deploying Web applications using `Gunicorn <https://gunicorn.org/>`_ or `uWSGI
1000+
<https://uwsgi-docs.readthedocs.io/en/latest/>`_ (or similar), multiple worker
1001+
processes are created to handle client requests. In such environments, avoid creating
1002+
file-based handlers directly in your web application. Instead, use a
1003+
:class:`SocketHandler` to log from the web application to a listener in a separate
1004+
process. This can be set up using a process management tool such as Supervisor - see
1005+
`Running a logging socket listener in production`_ for more details.
1006+
9851007

9861008
Using file rotation
9871009
-------------------

Doc/library/asyncio-eventloop.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ Creating network servers
631631
assumed and a list of multiple sockets will be returned (most likely
632632
one for IPv4 and another one for IPv6).
633633

634+
* The *port* parameter can be set to specify which port the server should
635+
listen on. If ``0`` or ``None`` (the default), a random unused port will
636+
be selected (note that if *host* resolves to multiple network interfaces,
637+
a different random port will be selected for each interface).
638+
634639
* *family* can be set to either :data:`socket.AF_INET` or
635640
:data:`~socket.AF_INET6` to force the socket to use IPv4 or IPv6.
636641
If not set, the *family* will be determined from host name
@@ -1238,9 +1243,10 @@ async/await code consider using the high-level
12381243

12391244
.. note::
12401245

1241-
The default asyncio event loop on **Windows** does not support
1242-
subprocesses. See :ref:`Subprocess Support on Windows
1243-
<asyncio-windows-subprocess>` for details.
1246+
On Windows, the default event loop :class:`ProactorEventLoop` supports
1247+
subprocesses, whereas :class:`SelectorEventLoop` does not. See
1248+
:ref:`Subprocess Support on Windows <asyncio-windows-subprocess>` for
1249+
details.
12441250

12451251
.. coroutinemethod:: loop.subprocess_exec(protocol_factory, *args, \
12461252
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \

Doc/library/asyncio-stream.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ TCP echo client using the :func:`asyncio.open_connection` function::
352352

353353
print(f'Send: {message!r}')
354354
writer.write(message.encode())
355+
await writer.drain()
355356

356357
data = await reader.read(100)
357358
print(f'Received: {data.decode()!r}')

Doc/library/concurrent.futures.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ that :class:`ProcessPoolExecutor` will not work in the interactive interpreter.
231231
Calling :class:`Executor` or :class:`Future` methods from a callable submitted
232232
to a :class:`ProcessPoolExecutor` will result in deadlock.
233233

234-
.. class:: ProcessPoolExecutor(max_workers=None, mp_context=None, initializer=None, initargs=())
234+
.. class:: ProcessPoolExecutor(max_workers=None, mp_context=None, initializer=None, initargs=(), max_tasks_per_child=None)
235235

236236
An :class:`Executor` subclass that executes calls asynchronously using a pool
237237
of at most *max_workers* processes. If *max_workers* is ``None`` or not
@@ -252,6 +252,11 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
252252
pending jobs will raise a :exc:`~concurrent.futures.process.BrokenProcessPool`,
253253
as well as any attempt to submit more jobs to the pool.
254254

255+
*max_tasks_per_child* is an optional argument that specifies the maximum
256+
number of tasks a single process can execute before it will exit and be
257+
replaced with a fresh worker process. The default *max_tasks_per_child* is
258+
``None`` which means worker processes will live as long as the pool.
259+
255260
.. versionchanged:: 3.3
256261
When one of the worker processes terminates abruptly, a
257262
:exc:`BrokenProcessPool` error is now raised. Previously, behaviour
@@ -264,6 +269,10 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
264269

265270
Added the *initializer* and *initargs* arguments.
266271

272+
.. versionchanged:: 3.11
273+
The *max_tasks_per_child* argument was added to allow users to
274+
control the lifetime of workers in the pool.
275+
267276

268277
.. _processpoolexecutor-example:
269278

Doc/library/contextlib.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ Functions and classes provided:
130130
either as decorators or with :keyword:`async with` statements::
131131

132132
import time
133+
from contextlib import asynccontextmanager
133134

135+
@asynccontextmanager
134136
async def timeit():
135137
now = time.monotonic()
136138
try:

0 commit comments

Comments
 (0)