Skip to content

Commit 60d7ef1

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix-structseq-unnamed
2 parents 49ea69f + cd98657 commit 60d7ef1

348 files changed

Lines changed: 7230 additions & 1883 deletions

File tree

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ jobs:
245245
os: ${{ matrix.os }}
246246
test-opts: ${{ matrix.test-opts || '' }}
247247

248+
build-ubuntu-installed:
249+
name: 'Ubuntu (installed)'
250+
needs: build-context
251+
if: needs.build-context.outputs.run-ubuntu == 'true'
252+
uses: ./.github/workflows/reusable-install.yml
253+
248254
build-ubuntu-ssltests:
249255
name: 'Ubuntu SSL tests'
250256
runs-on: ${{ matrix.os }}
@@ -636,6 +642,7 @@ jobs:
636642
- build-windows
637643
- build-macos
638644
- build-ubuntu
645+
- build-ubuntu-installed
639646
- build-ubuntu-ssltests
640647
- build-ios
641648
- build-emscripten
@@ -685,6 +692,7 @@ jobs:
685692
!fromJSON(needs.build-context.outputs.run-ubuntu)
686693
&& '
687694
build-ubuntu,
695+
build-ubuntu-installed,
688696
build-ubuntu-ssltests,
689697
test-hypothesis,
690698
build-asan,

.github/workflows/reusable-check-html-ids.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
with:
2121
persist-credentials: false
2222
ref: ${{ github.event.pull_request.head.sha }}
23+
- name: 'Downgrade Git'
24+
# Temporarily downgrade to 2.43 until 2.55 is in the runner image,
25+
# to avoid "fatal: shallow file has changed since we read it" bug.
26+
# See https://github.com/python/cpython/issues/151365.
27+
run: |
28+
sudo apt-get install -y --allow-downgrades 'git=1:2.43.*' 'git-man=1:2.43.*'
29+
git --version
2330
- name: 'Find merge base'
2431
id: merge-base
2532
run: |

.github/workflows/reusable-context.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ jobs:
9090
|| ''
9191
}}
9292
93+
- name: 'Downgrade Git'
94+
# Temporarily downgrade to 2.43 until 2.55 is in the runner image,
95+
# to avoid "fatal: shallow file has changed since we read it" bug.
96+
# See https://github.com/python/cpython/issues/151365.
97+
if: github.event_name == 'pull_request'
98+
run: |
99+
sudo apt-get install -y --allow-downgrades 'git=1:2.43.*' 'git-man=1:2.43.*'
100+
git --version
101+
93102
# Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
94103
- name: Fetch commits to get branch diff
95104
if: github.event_name == 'pull_request'

.github/workflows/reusable-docs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ jobs:
4747
&& github.event.pull_request.head.sha
4848
|| ''
4949
}}
50+
- name: 'Downgrade Git'
51+
# Temporarily downgrade to 2.43 until 2.55 is in the runner image,
52+
# to avoid "fatal: shallow file has changed since we read it" bug.
53+
# See https://github.com/python/cpython/issues/151365.
54+
if: github.event_name == 'pull_request'
55+
run: |
56+
sudo apt-get install -y --allow-downgrades 'git=1:2.43.*' 'git-man=1:2.43.*'
57+
git --version
5058
# Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
5159
- name: 'Fetch commits to get branch diff'
5260
if: github.event_name == 'pull_request'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Reusable Ubuntu (installed)
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
FORCE_COLOR: 1
11+
12+
jobs:
13+
build-install-test:
14+
name: build, install and test
15+
runs-on: ubuntu-26.04-arm
16+
timeout-minutes: 60
17+
env:
18+
PYTHONSTRICTEXTENSIONBUILD: 1
19+
steps:
20+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
21+
with:
22+
persist-credentials: false
23+
- name: Register gcc problem matcher
24+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
25+
- name: Set install dir
26+
run:
27+
echo "INSTALL_DIR=$(realpath "${GITHUB_WORKSPACE}/../installed-python")" >> "$GITHUB_ENV"
28+
- name: Install dependencies
29+
run: sudo ./.github/workflows/posix-deps-apt.sh
30+
- name: Configure CPython
31+
run: ./configure --config-cache --prefix="$INSTALL_DIR"
32+
- name: Build CPython
33+
run: make -j
34+
- name: Install CPython
35+
run: make install
36+
- name: Set installed interpreter
37+
run: |
38+
ldversion=$(./python -c 'import sysconfig; print(sysconfig.get_config_var("LDVERSION"))')
39+
echo "INSTALLED_PYTHON=${INSTALL_DIR}/bin/python${ldversion}" >> "$GITHUB_ENV"
40+
- name: Display build info
41+
run: |
42+
"$INSTALLED_PYTHON" -m test.pythoninfo
43+
- name: Test the installed Python
44+
run: xvfb-run "$INSTALLED_PYTHON" -m test --fast-ci --timeout=900

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Tools/unicode/data/
143143
/config.status.lineno
144144
/.ccache
145145
/cross-build*/
146+
/dist/
146147
/jit_stencils*.h
147148
/jit_unwind_info*.h
148149
.jit-stamp

Doc/c-api/arg.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,18 @@ inside nested parentheses. They are:
399399
their default value --- when an optional argument is not specified,
400400
:c:func:`PyArg_ParseTuple` does not touch the contents of the corresponding C
401401
variable(s).
402+
For example, the format string ``"OO|OO"`` corresponds to the Python
403+
signature ``f(a, b, c=None, d=None)``.
402404

403405
``$``
404406
:c:func:`PyArg_ParseTupleAndKeywords` only:
405407
Indicates that the remaining arguments in the Python argument list are
406-
keyword-only. Currently, all keyword-only arguments must also be optional
407-
arguments, so ``|`` must always be specified before ``$`` in the format
408-
string.
408+
keyword-only.
409+
They are optional if ``|`` was specified before ``$``, and required otherwise.
410+
``|`` cannot be specified after ``$``.
411+
For example, the format string ``"O|O$O"`` corresponds to the Python
412+
signature ``f(a, b=None, *, c=None)``,
413+
and the format string ``"OO$OO"`` corresponds to ``f(a, b, *, c, d)``.
409414

410415
.. versionadded:: 3.3
411416

Doc/c-api/capsule.rst

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,20 @@ Refer to :ref:`using-capsules` for more information on using these objects.
108108
109109
Import a pointer to a C object from a capsule attribute in a module. The
110110
*name* parameter should specify the full name to the attribute, as in
111-
``module.attribute``. The *name* stored in the capsule must match this
112-
string exactly.
113-
114-
This function splits *name* on the ``.`` character, and imports the first
115-
element. It then processes further elements using attribute lookups.
111+
``package.module.attribute``.
112+
Modules are imported if needed,
113+
other components are looked up as attributes.
114+
The *name* stored in the capsule must match this string exactly.
116115
117116
Return the capsule's internal *pointer* on success. On failure, set an
118117
exception and return ``NULL``.
119118
120-
.. note::
121-
122-
If *name* points to an attribute of some submodule or subpackage, this
123-
submodule or subpackage must be previously imported using other means
124-
(for example, by using :c:func:`PyImport_ImportModule`) for the
125-
attribute lookups to succeed.
126-
127119
.. versionchanged:: 3.3
128120
*no_block* has no effect anymore.
129121
122+
.. versionchanged:: next
123+
Submodules are now imported if needed.
124+
130125
131126
.. c:function:: int PyCapsule_IsValid(PyObject *capsule, const char *name)
132127

Doc/c-api/frame.rst

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -243,62 +243,3 @@ Unless using :pep:`523`, you will not need this.
243243
Return the currently executing line number, or -1 if there is no line number.
244244
245245
.. versionadded:: 3.12
246-
247-
248-
.. c:var:: const PyTypeObject *PyUnstable_ExecutableKinds
249-
250-
An array of executable kinds (executor types) for frames, used for internal
251-
debugging and tracing.
252-
253-
Tools like debuggers and profilers can use this to identify the type of execution
254-
context associated with a frame (such as to filter out internal frames).
255-
The entries are indexed by the following constants:
256-
257-
.. list-table::
258-
:header-rows: 1
259-
:widths: auto
260-
261-
* - Constant
262-
- Description
263-
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_SKIP
264-
- The frame is internal (For example: inlined) and should be skipped by tools.
265-
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_PY_FUNCTION
266-
- The frame corresponds to a standard Python function.
267-
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION
268-
- The frame corresponds to a function defined in native code.
269-
* - .. c:macro:: PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR
270-
- The frame corresponds to a method on a class instance.
271-
272-
However, Python's C API lacks a function to read the executable kind from
273-
a frame. Instead, use this recipe:
274-
275-
.. code-block:: c
276-
277-
int
278-
get_executable_kind(PyFrameObject *frame)
279-
{
280-
_PyInterpreterFrame *f = frame->f_frame;
281-
PyObject *exec = PyStackRef_AsPyObjectBorrow(f->f_executable);
282-
283-
if (PyCode_Check(exec)) {
284-
return PyUnstable_EXECUTABLE_KIND_PY_FUNCTION;
285-
}
286-
if (PyMethod_Check(exec)) {
287-
return PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION;
288-
}
289-
if (Py_IS_TYPE(exec, &PyMethodDescr_Type)) {
290-
return PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR;
291-
}
292-
293-
return PyUnstable_EXECUTABLE_KIND_SKIP;
294-
}
295-
296-
.. versionadded:: 3.13
297-
298-
299-
.. c:macro:: PyUnstable_EXECUTABLE_KINDS
300-
301-
The number of entries in :c:data:`PyUnstable_ExecutableKinds`.
302-
303-
.. versionadded:: 3.13
304-

Doc/library/argparse.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,12 +1564,12 @@ it exits and prints the error along with a usage message::
15641564
>>> # invalid option
15651565
>>> parser.parse_args(['--bar'])
15661566
usage: PROG [-h] [--foo FOO] [bar]
1567-
PROG: error: no such option: --bar
1567+
PROG: error: unrecognized arguments: --bar
15681568

15691569
>>> # wrong number of arguments
15701570
>>> parser.parse_args(['spam', 'badger'])
15711571
usage: PROG [-h] [--foo FOO] [bar]
1572-
PROG: error: extra arguments found: badger
1572+
PROG: error: unrecognized arguments: badger
15731573

15741574

15751575
Arguments containing ``-``
@@ -1606,7 +1606,7 @@ there are no options in the parser that look like negative numbers::
16061606
>>> # negative number options present, so -2 is an option
16071607
>>> parser.parse_args(['-2'])
16081608
usage: PROG [-h] [-1 ONE] [foo]
1609-
PROG: error: no such option: -2
1609+
PROG: error: unrecognized arguments: -2
16101610

16111611
>>> # negative number options present, so both -1s are options
16121612
>>> parser.parse_args(['-1', '-1'])
@@ -1624,6 +1624,11 @@ argument::
16241624
See also :ref:`the argparse howto on ambiguous arguments <specifying-ambiguous-arguments>`
16251625
for more details.
16261626

1627+
.. versionchanged:: 3.14
1628+
Negative-number matching was expanded to include numbers in scientific
1629+
notation (``-2.5e-6``), numbers containing underscores (``-1_234.5``),
1630+
and complex numbers (``-1.2e-3j``).
1631+
16271632
.. _prefix-matching:
16281633

16291634
Argument abbreviations (prefix matching)
@@ -1679,6 +1684,12 @@ The Namespace object
16791684
Simple class used by default by :meth:`~ArgumentParser.parse_args` to create
16801685
an object holding attributes and return it.
16811686

1687+
:class:`!Namespace` objects support :func:`copy.replace`,
1688+
which returns a copy of the object with the specified attributes replaced.
1689+
1690+
.. versionchanged:: next
1691+
Added support for :func:`copy.replace`.
1692+
16821693
This class is deliberately simple, just an :class:`object` subclass with a
16831694
readable string representation. If you prefer to have dict-like view of the
16841695
attributes, you can use the standard Python idiom, :func:`vars`::

0 commit comments

Comments
 (0)