Skip to content

Commit baa8a0d

Browse files
authored
Merge branch 'main' into windows-aarch64-runners
2 parents 342af93 + b6c92ec commit baa8a0d

File tree

121 files changed

+6441
-3465
lines changed

Some content is hidden

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

121 files changed

+6441
-3465
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ Python/ast_opt.c @isidentical @eclips4
188188
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
189189
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
190190
Lib/ast.py @isidentical @JelleZijlstra @eclips4
191+
Lib/_ast_unparse.py @isidentical @JelleZijlstra @eclips4
191192
Lib/test/test_ast/ @eclips4
192193

193194
# Mock

Doc/c-api/type.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ Type Objects
8282
error (e.g. no more watcher IDs available), return ``-1`` and set an
8383
exception.
8484
85+
In free-threaded builds, :c:func:`PyType_AddWatcher` is not thread-safe,
86+
so it must be called at start up (before spawning the first thread).
87+
8588
.. versionadded:: 3.12
8689
8790

Doc/library/annotationlib.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,30 +172,38 @@ Classes
172172
:class:`~ForwardRef`. The string may not be exactly equivalent
173173
to the original source.
174174

175-
.. method:: evaluate(*, globals=None, locals=None, type_params=None, owner=None)
175+
.. method:: evaluate(*, owner=None, globals=None, locals=None, type_params=None)
176176

177177
Evaluate the forward reference, returning its value.
178178

179179
This may throw an exception, such as :exc:`NameError`, if the forward
180-
reference refers to names that do not exist. The arguments to this
180+
reference refers to a name that cannot be resolved. The arguments to this
181181
method can be used to provide bindings for names that would otherwise
182182
be undefined.
183183

184+
The *owner* parameter provides the preferred mechanism for passing scope
185+
information to this method. The owner of a :class:`~ForwardRef` is the
186+
object that contains the annotation from which the :class:`~ForwardRef`
187+
derives, such as a module object, type object, or function object.
188+
189+
The *globals*, *locals*, and *type_params* parameters provide a more precise
190+
mechanism for influencing the names that are available when the :class:`~ForwardRef`
191+
is evaluated. *globals* and *locals* are passed to :func:`eval`, representing
192+
the global and local namespaces in which the name is evaluated.
193+
The *type_params* parameter is relevant for objects created using the native
194+
syntax for :ref:`generic classes <generic-classes>` and :ref:`functions <generic-functions>`.
195+
It is a tuple of :ref:`type parameters <type-params>` that are in scope
196+
while the forward reference is being evaluated. For example, if evaluating a
197+
:class:`~ForwardRef` retrieved from an annotation found in the class namespace
198+
of a generic class ``C``, *type_params* should be set to ``C.__type_params__``.
199+
184200
:class:`~ForwardRef` instances returned by :func:`get_annotations`
185201
retain references to information about the scope they originated from,
186202
so calling this method with no further arguments may be sufficient to
187203
evaluate such objects. :class:`~ForwardRef` instances created by other
188204
means may not have any information about their scope, so passing
189205
arguments to this method may be necessary to evaluate them successfully.
190206

191-
*globals* and *locals* are passed to :func:`eval`, representing
192-
the global and local namespaces in which the name is evaluated.
193-
*type_params*, if given, must be a tuple of
194-
:ref:`type parameters <type-params>` that are in scope while the forward
195-
reference is being evaluated. *owner* is the object that owns the
196-
annotation from which the forward reference derives, usually a function,
197-
class, or module.
198-
199207
.. important::
200208

201209
Once a :class:`~ForwardRef` instance has been evaluated, it caches

Doc/library/dis.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ the following command can be used to display the disassembly of
7676
2 RESUME 0
7777
<BLANKLINE>
7878
3 LOAD_GLOBAL 1 (len + NULL)
79-
LOAD_FAST 0 (alist)
79+
LOAD_FAST_BORROW 0 (alist)
8080
CALL 1
8181
RETURN_VALUE
8282

@@ -215,7 +215,7 @@ Example:
215215
...
216216
RESUME
217217
LOAD_GLOBAL
218-
LOAD_FAST
218+
LOAD_FAST_BORROW
219219
CALL
220220
RETURN_VALUE
221221

@@ -1402,13 +1402,28 @@ iterations of the loop.
14021402
This opcode is now only used in situations where the local variable is
14031403
guaranteed to be initialized. It cannot raise :exc:`UnboundLocalError`.
14041404

1405+
.. opcode:: LOAD_FAST_BORROW (var_num)
1406+
1407+
Pushes a borrowed reference to the local ``co_varnames[var_num]`` onto the
1408+
stack.
1409+
1410+
.. versionadded:: 3.14
1411+
14051412
.. opcode:: LOAD_FAST_LOAD_FAST (var_nums)
14061413

14071414
Pushes references to ``co_varnames[var_nums >> 4]`` and
14081415
``co_varnames[var_nums & 15]`` onto the stack.
14091416

14101417
.. versionadded:: 3.13
14111418

1419+
1420+
.. opcode:: LOAD_FAST_BORROW_LOAD_FAST_BORROW (var_nums)
1421+
1422+
Pushes borrowed references to ``co_varnames[var_nums >> 4]`` and
1423+
``co_varnames[var_nums & 15]`` onto the stack.
1424+
1425+
.. versionadded:: 3.14
1426+
14121427
.. opcode:: LOAD_FAST_CHECK (var_num)
14131428

14141429
Pushes a reference to the local ``co_varnames[var_num]`` onto the stack,
@@ -2023,4 +2038,3 @@ instructions:
20232038

20242039
.. deprecated:: 3.13
20252040
All jumps are now relative. This list is empty.
2026-

Doc/library/linecache.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ The :mod:`linecache` module defines the following functions:
3030

3131
.. index:: triple: module; search; path
3232

33+
If *filename* indicates a frozen module (starting with ``'<frozen '``), the function
34+
will attepmt to get the real file name from ``module_globals['__file__']`` if
35+
*module_globals* is not ``None``.
36+
3337
If a file named *filename* is not found, the function first checks
3438
for a :pep:`302` ``__loader__`` in *module_globals*.
3539
If there is such a loader and it defines a ``get_source`` method,
@@ -38,6 +42,10 @@ The :mod:`linecache` module defines the following functions:
3842
Finally, if *filename* is a relative filename,
3943
it is looked up relative to the entries in the module search path, ``sys.path``.
4044

45+
.. versionchanged:: 3.14
46+
47+
Support *filename* of frozen modules.
48+
4149

4250
.. function:: clearcache()
4351

Doc/library/sys.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,28 @@ always available. Unless explicitly noted otherwise, all variables are read-only
18351835

18361836
.. versionadded:: 3.12
18371837

1838+
1839+
.. function:: remote_exec(pid, script)
1840+
1841+
Executes *script*, a file containing Python code in the remote
1842+
process with the given *pid*.
1843+
1844+
This function returns immediately, and the code will be executed by the
1845+
target process's main thread at the next available opportunity, similarly
1846+
to how signals are handled. There is no interface to determine when the
1847+
code has been executed. The caller is responsible for making sure that
1848+
the file still exists whenever the remote process tries to read it and that
1849+
it hasn't been overwritten.
1850+
1851+
The remote process must be running a CPython interpreter of the same major
1852+
and minor version as the local process. If either the local or remote
1853+
interpreter is pre-release (alpha, beta, or release candidate) then the
1854+
local and remote interpreters must be the same exact version.
1855+
1856+
.. availability:: Unix, Windows.
1857+
.. versionadded:: next
1858+
1859+
18381860
.. function:: _enablelegacywindowsfsencoding()
18391861

18401862
Changes the :term:`filesystem encoding and error handler` to 'mbcs' and

Doc/library/typing.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,16 +3466,8 @@ Introspection helpers
34663466
* Supports the :attr:`~annotationlib.Format.FORWARDREF` and
34673467
:attr:`~annotationlib.Format.STRING` formats.
34683468

3469-
*forward_ref* must be an instance of :class:`~annotationlib.ForwardRef`.
3470-
*owner*, if given, should be the object that holds the annotations that
3471-
the forward reference derived from, such as a module, class object, or function.
3472-
It is used to infer the namespaces to use for looking up names.
3473-
*globals* and *locals* can also be explicitly given to provide
3474-
the global and local namespaces.
3475-
*type_params* is a tuple of :ref:`type parameters <type-params>` that
3476-
are in scope when evaluating the forward reference.
3477-
This parameter must be provided (though it may be an empty tuple) if *owner*
3478-
is not given and the forward reference does not already have an owner set.
3469+
See the documentation for :meth:`annotationlib.ForwardRef.evaluate` for
3470+
the meaning of the *owner*, *globals*, *locals*, and *type_params* parameters.
34793471
*format* specifies the format of the annotation and is a member of
34803472
the :class:`annotationlib.Format` enum.
34813473

Doc/reference/compound_stmts.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ Additional information on exceptions can be found in section :ref:`exceptions`,
232232
and information on using the :keyword:`raise` statement to generate exceptions
233233
may be found in section :ref:`raise`.
234234

235+
.. versionchanged:: next
236+
Support for optionally dropping grouping parentheses when using multiple exception types. See :pep:`758`.
235237

236238
.. _except:
237239

@@ -247,7 +249,8 @@ An expression-less :keyword:`!except` clause, if present, must be last;
247249
it matches any exception.
248250

249251
For an :keyword:`!except` clause with an expression, the
250-
expression must evaluate to an exception type or a tuple of exception types.
252+
expression must evaluate to an exception type or a tuple of exception types. Parentheses
253+
can be dropped if multiple exception types are provided and the ``as`` clause is not used.
251254
The raised exception matches an :keyword:`!except` clause whose expression evaluates
252255
to the class or a :term:`non-virtual base class <abstract base class>` of the exception object,
253256
or to a tuple that contains such a class.

Doc/using/cmdline.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,17 @@ Miscellaneous options
603603

604604
.. versionadded:: 3.13
605605

606+
* ``-X disable_remote_debug`` disables the remote debugging support as described
607+
in :pep:`768`. This includes both the functionality to schedule code for
608+
execution in another process and the functionality to receive code for
609+
execution in the current process.
610+
611+
This option is only available on some platforms and will do nothing
612+
if is not supported on the current system. See also
613+
:envvar:`PYTHON_DISABLE_REMOTE_DEBUG` and :pep:`768`.
614+
615+
.. versionadded:: next
616+
606617
* :samp:`-X cpu_count={n}` overrides :func:`os.cpu_count`,
607618
:func:`os.process_cpu_count`, and :func:`multiprocessing.cpu_count`.
608619
*n* must be greater than or equal to 1.
@@ -1160,7 +1171,16 @@ conflict.
11601171

11611172
.. versionadded:: 3.13
11621173

1174+
.. envvar:: PYTHON_DISABLE_REMOTE_DEBUG
1175+
1176+
If this variable is set to a non-empty string, it disables the remote
1177+
debugging feature described in :pep:`768`. This includes both the functionality
1178+
to schedule code for execution in another process and the functionality to
1179+
receive code for execution in the current process.
1180+
1181+
See also the :option:`-X disable_remote_debug` command-line option.
11631182

1183+
.. versionadded:: next
11641184

11651185
.. envvar:: PYTHON_CPU_COUNT
11661186

Doc/using/configure.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,17 @@ also be used to improve performance.
660660
Add ``-fstrict-overflow`` to the C compiler flags (by default we add
661661
``-fno-strict-overflow`` instead).
662662

663+
.. option:: --without-remote-debug
664+
665+
Deactivate remote debugging support described in :pep:`768` (enabled by default).
666+
When this flag is provided the code that allows the interpreter to schedule the
667+
execution of a Python file in a separate process as described in :pep:`768` is
668+
not compiled. This includes both the functionality to schedule code to be executed
669+
and the functionality to receive code to be executed.
670+
671+
672+
.. versionadded:: next
673+
663674

664675
.. _debug-build:
665676

0 commit comments

Comments
 (0)