Skip to content

Commit 18022f3

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix/ubsan/clinic-test-111178
2 parents 54a80c8 + 305be5f commit 18022f3

File tree

176 files changed

+7038
-3683
lines changed

Some content is hidden

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

176 files changed

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

.github/workflows/build.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ jobs:
164164
- false
165165
- true
166166
include:
167-
- os: windows-latest # FIXME(diegorusso): change to os: windows-aarch64
167+
# Forks don't have access to Windows on Arm runners. These jobs are skipped below:
168+
- os: ${{ github.repository_owner == 'python' && 'windows-aarch64' || 'windows-latest' }}
168169
arch: arm64
169170
free-threading: false
170-
- os: windows-latest # FIXME(diegorusso): change to os: windows-aarch64
171+
# Forks don't have access to Windows on Arm runners. These jobs are skipped below:
172+
- os: ${{ github.repository_owner == 'python' && 'windows-aarch64' || 'windows-latest' }}
171173
arch: arm64
172174
free-threading: true
173175
- os: windows-latest
@@ -187,12 +189,18 @@ jobs:
187189
strategy:
188190
fail-fast: false
189191
matrix:
192+
os:
193+
- windows-latest
190194
arch:
191195
- x86
192196
- x64
193-
- arm64
197+
include:
198+
# Forks don't have access to Windows on Arm runners. These jobs are skipped below:
199+
- os: ${{ github.repository_owner == 'python' && 'windows-aarch64' || 'windows-latest' }}
200+
arch: arm64
194201
uses: ./.github/workflows/reusable-windows-msi.yml
195202
with:
203+
os: ${{ matrix.os }}
196204
arch: ${{ matrix.arch }}
197205

198206
build-macos:

.github/workflows/jit.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ jobs:
7474
runner: windows-latest
7575
- target: aarch64-pc-windows-msvc/msvc
7676
architecture: ARM64
77-
runner: windows-latest
77+
# Forks don't have access to Windows on Arm runners. These jobs are skipped below:
78+
runner: ${{ github.repository_owner == 'python' && 'windows-aarch64' || 'windows-latest' }}
7879
- target: x86_64-apple-darwin/clang
7980
architecture: x86_64
8081
runner: macos-13
@@ -95,25 +96,19 @@ jobs:
9596
with:
9697
python-version: '3.11'
9798

98-
- name: Native Windows
99-
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
99+
- name: Windows
100+
# Forks don't have access to Windows on Arm runners. Skip those:
101+
if: runner.os == 'Windows' && (matrix.architecture != 'ARM64' || github.repository_owner == 'python')
100102
run: |
101103
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
102104
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
103105
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
104106
105-
# No tests (yet):
106-
- name: Emulated Windows
107-
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
108-
run: |
109-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
110-
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
111-
112107
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
113108
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
114109
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
115110
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
116-
- name: Native macOS
111+
- name: macOS
117112
if: runner.os == 'macOS'
118113
run: |
119114
brew update
@@ -124,7 +119,7 @@ jobs:
124119
make all --jobs 4
125120
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
126121
127-
- name: Native Linux
122+
- name: Linux
128123
if: runner.os == 'Linux'
129124
run: |
130125
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}

.github/workflows/reusable-windows-msi.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Reusable Windows MSI
33
on:
44
workflow_call:
55
inputs:
6+
os:
7+
description: OS to run on
8+
required: true
9+
type: string
610
arch:
711
description: CPU architecture
812
required: true
@@ -17,7 +21,7 @@ env:
1721
jobs:
1822
build:
1923
name: installer for ${{ inputs.arch }}
20-
runs-on: windows-latest
24+
runs-on: ${{ inputs.os }}
2125
timeout-minutes: 60
2226
env:
2327
ARCH: ${{ inputs.arch }}
@@ -27,5 +31,7 @@ jobs:
2731
with:
2832
persist-credentials: false
2933
- name: Build CPython installer
34+
# Forks don't have access to Windows on Arm runners. Skip those:
35+
if: inputs.arch != 'arm64' || github.repository_owner == 'python'
3036
run: ./Tools/msi/build.bat --doc -"${ARCH}"
3137
shell: bash

.github/workflows/reusable-windows.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ env:
2424
2525
jobs:
2626
build:
27-
name: ${{ inputs.arch == 'arm64' && 'build' || 'build and test' }} (${{ inputs.arch }})
27+
name: Build and test (${{ inputs.arch }})
2828
runs-on: ${{ inputs.os }}
2929
timeout-minutes: 60
3030
env:
@@ -37,17 +37,21 @@ jobs:
3737
if: inputs.arch != 'Win32'
3838
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3939
- name: Build CPython
40+
# Forks don't have access to Windows on Arm runners. Skip those:
41+
if: inputs.arch != 'arm64' || github.repository_owner == 'python'
4042
run: >-
4143
.\\PCbuild\\build.bat
4244
-e -d -v
4345
-p "${ARCH}"
4446
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
4547
shell: bash
46-
- name: Display build info # FIXME(diegorusso): remove the `if`
47-
if: inputs.arch != 'arm64'
48+
- name: Display build info
49+
# Forks don't have access to Windows on Arm runners. Skip those:
50+
if: inputs.arch != 'arm64' || github.repository_owner == 'python'
4851
run: .\\python.bat -m test.pythoninfo
49-
- name: Tests # FIXME(diegorusso): remove the `if`
50-
if: inputs.arch != 'arm64'
52+
- name: Tests
53+
# Forks don't have access to Windows on Arm runners. Skip those:
54+
if: inputs.arch != 'arm64' || github.repository_owner == 'python'
5155
run: >-
5256
.\\PCbuild\\rt.bat
5357
-p "${ARCH}"

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

0 commit comments

Comments
 (0)