Skip to content

Commit bb1bff8

Browse files
authored
Merge branch 'main' into unicode-stringprep
2 parents 5ae2c33 + 63bf95b commit bb1bff8

51 files changed

Lines changed: 569 additions & 210 deletions

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,
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

Doc/library/argparse.rst

Lines changed: 8 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)

Doc/library/asyncio-task.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,12 @@ Eager task factory
668668
Shielding from cancellation
669669
===========================
670670

671-
.. awaitablefunction:: shield(aw)
671+
.. awaitablefunction:: shield(arg)
672672

673673
Protect an :ref:`awaitable object <asyncio-awaitables>`
674674
from being :meth:`cancelled <Task.cancel>`.
675675

676-
If *aw* is a coroutine it is automatically scheduled as a Task.
676+
If *arg* is a coroutine it is automatically scheduled as a Task.
677677

678678
The statement::
679679

@@ -714,7 +714,7 @@ Shielding from cancellation
714714
Removed the *loop* parameter.
715715

716716
.. deprecated:: 3.10
717-
Deprecation warning is emitted if *aw* is not Future-like object
717+
Deprecation warning is emitted if *arg* is not Future-like object
718718
and there is no running event loop.
719719

720720

@@ -837,13 +837,13 @@ Timeouts
837837

838838
.. versionadded:: 3.11
839839

840-
.. function:: wait_for(aw, timeout)
840+
.. function:: wait_for(fut, timeout)
841841
:async:
842842

843-
Wait for the *aw* :ref:`awaitable <asyncio-awaitables>`
843+
Wait for the *fut* :ref:`awaitable <asyncio-awaitables>`
844844
to complete with a timeout.
845845

846-
If *aw* is a coroutine it is automatically scheduled as a Task.
846+
If *fut* is a coroutine it is automatically scheduled as a Task.
847847

848848
*timeout* can either be ``None`` or a float or int number of seconds
849849
to wait for. If *timeout* is ``None``, block until the future
@@ -859,7 +859,7 @@ Timeouts
859859
so the total wait time may exceed the *timeout*. If an exception
860860
happens during cancellation, it is propagated.
861861

862-
If the wait is cancelled, the future *aw* is also cancelled.
862+
If the wait is cancelled, the future *fut* is also cancelled.
863863

864864
.. _asyncio_example_waitfor:
865865

@@ -884,8 +884,8 @@ Timeouts
884884
# timeout!
885885

886886
.. versionchanged:: 3.7
887-
When *aw* is cancelled due to a timeout, ``wait_for`` waits
888-
for *aw* to be cancelled. Previously, it raised
887+
When *fut* is cancelled due to a timeout, ``wait_for`` waits
888+
for *fut* to be cancelled. Previously, it raised
889889
:exc:`TimeoutError` immediately.
890890

891891
.. versionchanged:: 3.10
@@ -898,20 +898,20 @@ Timeouts
898898
Waiting primitives
899899
==================
900900

901-
.. function:: wait(aws, *, timeout=None, return_when=ALL_COMPLETED)
901+
.. function:: wait(fs, *, timeout=None, return_when=ALL_COMPLETED)
902902
:async:
903903

904-
Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the *aws*
904+
Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the *fs*
905905
iterable concurrently and block until the condition specified
906906
by *return_when*.
907907

908-
The *aws* iterable must not be empty.
908+
The *fs* iterable must not be empty.
909909

910910
Returns two sets of Tasks/Futures: ``(done, pending)``.
911911

912912
Usage::
913913

914-
done, pending = await asyncio.wait(aws)
914+
done, pending = await asyncio.wait(fs)
915915

916916
*timeout* (a float or int), if specified, can be used to control
917917
the maximum number of seconds to wait before returning.
@@ -943,7 +943,7 @@ Waiting primitives
943943
Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the
944944
futures when a timeout occurs.
945945

946-
If ``wait()`` is cancelled, the futures in *aws* are not cancelled
946+
If ``wait()`` is cancelled, the futures in *fs* are not cancelled
947947
and continue to run.
948948

949949
.. versionchanged:: 3.10
@@ -956,9 +956,9 @@ Waiting primitives
956956
Added support for generators yielding tasks.
957957

958958

959-
.. function:: as_completed(aws, *, timeout=None)
959+
.. function:: as_completed(fs, *, timeout=None)
960960

961-
Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws* iterable
961+
Run :ref:`awaitable objects <asyncio-awaitables>` in the *fs* iterable
962962
concurrently. The returned object can be iterated to obtain the results
963963
of the awaitables as they finish.
964964

@@ -1011,7 +1011,7 @@ Waiting primitives
10111011
Removed the *loop* parameter.
10121012

10131013
.. deprecated:: 3.10
1014-
Deprecation warning is emitted if not all awaitable objects in the *aws*
1014+
Deprecation warning is emitted if not all awaitable objects in the *fs*
10151015
iterable are Future-like objects and there is no running event loop.
10161016

10171017
.. versionchanged:: 3.12

Doc/library/inspect.rst

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,10 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
707707
Retrieving source code
708708
----------------------
709709

710-
.. function:: getdoc(object, *, inherit_class_doc=True, fallback_to_class_doc=True)
710+
.. function:: getdoc(object, *, inherit_class_doc=True, fallback_to_class_doc=True, dedent=True)
711711

712-
Get the documentation string for an object, cleaned up with :func:`cleandoc`.
712+
Get the documentation string for an object, cleaned up with :func:`cleandoc`
713+
(with the same meaning of *dedent*).
713714
If the documentation string for an object is not provided:
714715

715716
* if the object is a class and *inherit_class_doc* is true (by default),
@@ -730,6 +731,9 @@ Retrieving source code
730731
Documentation strings on :class:`~functools.cached_property`
731732
objects are now inherited if not overridden.
732733

734+
.. versionchanged:: next
735+
Added the *dedent* parameter.
736+
733737

734738
.. function:: getcomments(object)
735739

@@ -791,15 +795,23 @@ Retrieving source code
791795
former.
792796

793797

794-
.. function:: cleandoc(doc)
798+
.. function:: cleandoc(doc, *, dedent=True)
795799

796800
Clean up indentation from docstrings that are indented to line up with blocks
797801
of code.
798802

799803
All leading whitespace is removed from the first line. Any leading whitespace
800-
that can be uniformly removed from the second line onwards is removed. Empty
801-
lines at the beginning and end are subsequently removed. Also, all tabs are
802-
expanded to spaces.
804+
that can be uniformly removed from the second line onwards is removed, unless
805+
*dedent* is false. Empty lines at the beginning and end are subsequently
806+
removed. Also, all tabs are expanded to spaces.
807+
808+
Since Python 3.13 the compiler removes the indentation of docstrings, so
809+
*dedent* only affects documentation strings which are not written as
810+
docstrings in the source code, like those generated by Argument Clinic,
811+
where the indentation is meaningful.
812+
813+
.. versionchanged:: next
814+
Added the *dedent* parameter.
803815

804816

805817
.. _inspect-signature-object:

Doc/library/test.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,32 @@ The :mod:`!test.support.os_helper` module provides support for os tests.
16561656
wrapped with a wait loop that checks for the existence of the file.
16571657

16581658

1659+
.. decorator:: with_source_date_epoch(*, epoch=123456789)
1660+
1661+
A decorator for running tests with the :envvar:`SOURCE_DATE_EPOCH`
1662+
environment variable set to *epoch*.
1663+
1664+
1665+
.. decorator:: without_source_date_epoch
1666+
1667+
A decorator for running tests with the :envvar:`SOURCE_DATE_EPOCH`
1668+
environment variable unset.
1669+
1670+
1671+
.. class:: SourceDateEpochTestMeta
1672+
1673+
Metaclass wrapping all test methods of the class with
1674+
:func:`with_source_date_epoch` if the *source_date_epoch* keyword class
1675+
argument is true, or with :func:`without_source_date_epoch` otherwise.
1676+
For example::
1677+
1678+
class TestsWithSourceEpoch(Tests,
1679+
metaclass=SourceDateEpochTestMeta,
1680+
source_date_epoch=True):
1681+
pass
1682+
1683+
1684+
16591685
:mod:`!test.support.import_helper` --- Utilities for import tests
16601686
=================================================================
16611687

Doc/whatsnew/3.16.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,17 @@ tarfile
727727
* The undocumented and unused :attr:`!tarfile.TarFile.tarfile` attribute
728728
has been deprecated since Python 3.13.
729729

730+
xml.etree.ElementTree
731+
---------------------
732+
733+
* The undocumented :meth:`!xml.etree.ElementTree.ElementTree.write_c14n` method
734+
and the support of ``method="c14n"`` in
735+
:meth:`~xml.etree.ElementTree.ElementTree.write` and
736+
:func:`~xml.etree.ElementTree.tostring`.
737+
They never worked and always raised :exc:`ValueError`.
738+
Use :func:`xml.etree.ElementTree.canonicalize` instead.
739+
(Contributed by Daniel Hillier in :gh:`118318`.)
740+
730741
.. Add removals above alphabetically, not here at the end.
731742
732743

Lib/_pyio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def getbuffer(self):
921921

922922
def close(self):
923923
if self._buffer is not None:
924-
self._buffer.clear()
924+
self._buffer = bytearray()
925925
super().close()
926926

927927
def read(self, size=-1):

Lib/argparse.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,11 +2917,14 @@ def print_help(self, file=None):
29172917
self._print_message(help_text, file)
29182918

29192919
def _print_message(self, message, file=None):
2920-
if message:
2921-
file = file or _sys.stderr
2920+
if not message:
2921+
return
2922+
if file is None:
2923+
file = _sys.stderr
2924+
if file is not None:
29222925
try:
29232926
file.write(message)
2924-
except (AttributeError, OSError):
2927+
except OSError:
29252928
pass
29262929

29272930
def _get_theme(self, file=None):

Lib/contextlib.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,20 @@ def __enter__(self):
199199
# do not keep args and kwds alive unnecessarily
200200
# they are only needed for recreation, which is not possible anymore
201201
del self.args, self.kwds, self.func
202-
try:
203-
return next(self.gen)
204-
except StopIteration:
205-
raise RuntimeError("generator didn't yield") from None
202+
# Slightly faster way to return next(self.gen):
203+
for once in self.gen:
204+
return once
205+
raise RuntimeError("generator didn't yield")
206206

207207
def __exit__(self, typ, value, traceback):
208208
if typ is None:
209-
try:
210-
next(self.gen)
211-
except StopIteration:
212-
return False
213-
else:
209+
# Faster way to run next(self.gen) and check for StopIteration:
210+
for _ in self.gen:
214211
try:
215212
raise RuntimeError("generator didn't stop")
216213
finally:
217214
self.gen.close()
215+
return False
218216
else:
219217
if value is None:
220218
# Need to force instantiation so we can reliably

0 commit comments

Comments
 (0)