Skip to content

Commit efd02d3

Browse files
authored
Merge branch 'main' into add-gdb-support
2 parents aa959c1 + 4e3811f commit efd02d3

105 files changed

Lines changed: 3328 additions & 2594 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/posix-deps-apt.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ apt-get -yq --no-install-recommends install \
2626
xvfb \
2727
zlib1g-dev
2828

29-
# Workaround missing libmpdec-dev on ubuntu 24.04:
30-
# https://launchpad.net/~ondrej/+archive/ubuntu/php
31-
# https://deb.sury.org/
32-
sudo add-apt-repository ppa:ondrej/php
33-
apt-get update
34-
apt-get -yq --no-install-recommends install libmpdec-dev
29+
# Workaround missing libmpdec-dev on ubuntu 24.04 by building mpdecimal
30+
# from source. ppa:ondrej/php (launchpad.net) are unreliable
31+
# (https://status.canonical.com) so fetch the tarball directly
32+
# from the upstream host.
33+
# https://www.bytereef.org/mpdecimal/
34+
MPDECIMAL_VERSION=4.0.1
35+
curl -fsSL "https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-${MPDECIMAL_VERSION}.tar.gz" \
36+
| tar -xz -C /tmp
37+
(cd "/tmp/mpdecimal-${MPDECIMAL_VERSION}" \
38+
&& ./configure --prefix=/usr/local \
39+
&& make -j"$(nproc)" \
40+
&& make install)
41+
ldconfig

Doc/library/email.policy.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,26 @@ added matters. To illustrate::
403403
.. attribute:: utf8
404404

405405
If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in
406-
headers by encoding them as "encoded words". If ``True``, follow
407-
:rfc:`6532` and use ``utf-8`` encoding for headers. Messages
406+
headers by encoding them as :rfc:`2047` "encoded words". If ``True``,
407+
follow :rfc:`6532` and use ``utf-8`` encoding for headers. Messages
408408
formatted in this way may be passed to SMTP servers that support
409409
the ``SMTPUTF8`` extension (:rfc:`6531`).
410410

411+
When ``False``, the generator will raise
412+
:exc:`~email.errors.HeaderWriteError` if any header includes non-ASCII
413+
characters in a context where :rfc:`2047` does not permit encoded words.
414+
This particularly applies to mailboxes ("addr-spec") with non-ASCII
415+
characters, which can be created via
416+
:class:`~email.headerregistry.Address`. To use a mailbox with a non-ASCII
417+
domain name with ``utf8=False``, first encode the domain using the
418+
third-party :pypi:`idna` or :pypi:`uts46` module or with
419+
:mod:`encodings.idna`. It is not possible to use a non-ASCII username
420+
("local-part") in a mailbox when ``utf8=False``.
421+
422+
.. versionchanged:: 3.15
423+
Can trigger the raising of :exc:`~email.errors.HeaderWriteError`.
424+
(Earlier versions incorrectly applied :rfc:`2047` in certain contexts,
425+
mostly notably in addr-specs.)
411426

412427
.. attribute:: refold_source
413428

Doc/library/faulthandler.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ tracebacks:
3131
* Each string is limited to 500 characters.
3232
* Only the filename, the function name and the line number are
3333
displayed. (no source code)
34-
* It is limited to 100 frames and 100 threads.
34+
* It is limited to 100 frames per thread, and 100 threads
35+
(configurable via *max_threads*).
3536
* The order is reversed: the most recent call is shown first.
3637

3738
By default, the Python traceback is written to :data:`sys.stderr`. To see
@@ -55,16 +56,20 @@ at Python startup.
5556
Dumping the traceback
5657
---------------------
5758

58-
.. function:: dump_traceback(file=sys.stderr, all_threads=True)
59+
.. function:: dump_traceback(file=sys.stderr, all_threads=True, *, max_threads=100)
5960

6061
Dump the tracebacks of all threads into *file*. If *all_threads* is
61-
``False``, dump only the current thread.
62+
``False``, dump only the current thread. *max_threads* caps the number
63+
of threads dumped.
6264

6365
.. seealso:: :func:`traceback.print_tb`, which can be used to print a traceback object.
6466

6567
.. versionchanged:: 3.5
6668
Added support for passing file descriptor to this function.
6769

70+
.. versionchanged:: next
71+
Added the *max_threads* keyword argument.
72+
6873

6974
Dumping the C stack
7075
-------------------
@@ -100,7 +105,7 @@ instead of the stack, even if the operating system supports dumping stacks.
100105
Fault handler state
101106
-------------------
102107

103-
.. function:: enable(file=sys.stderr, all_threads=True, c_stack=True)
108+
.. function:: enable(file=sys.stderr, all_threads=True, c_stack=True, *, max_threads=100)
104109

105110
Enable the fault handler: install handlers for the :const:`~signal.SIGSEGV`,
106111
:const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS`
@@ -116,6 +121,8 @@ Fault handler state
116121
traceback, unless the system does not support it. See :func:`dump_c_stack` for
117122
more information on compatibility.
118123

124+
*max_threads* caps the number of threads dumped when a fatal signal fires.
125+
119126
.. versionchanged:: 3.5
120127
Added support for passing file descriptor to this function.
121128

@@ -133,6 +140,9 @@ Fault handler state
133140
.. versionchanged:: 3.14
134141
The dump now displays the C stack trace if *c_stack* is true.
135142

143+
.. versionchanged:: next
144+
Added the *max_threads* keyword argument.
145+
136146
.. function:: disable()
137147

138148
Disable the fault handler: uninstall the signal handlers installed by
@@ -146,15 +156,15 @@ Fault handler state
146156
Dumping the tracebacks after a timeout
147157
--------------------------------------
148158

149-
.. function:: dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False)
159+
.. function:: dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False, *, max_threads=100)
150160

151161
Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or
152162
every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, call
153163
:c:func:`!_exit` with status=1 after dumping the tracebacks. (Note
154164
:c:func:`!_exit` exits the process immediately, which means it doesn't do any
155165
cleanup like flushing file buffers.) If the function is called twice, the new
156166
call replaces previous parameters and resets the timeout. The timer has a
157-
sub-second resolution.
167+
sub-second resolution. *max_threads* caps the number of threads dumped.
158168

159169
The *file* must be kept open until the traceback is dumped or
160170
:func:`cancel_dump_traceback_later` is called: see :ref:`issue with file
@@ -168,6 +178,9 @@ Dumping the tracebacks after a timeout
168178
.. versionchanged:: 3.7
169179
This function is now always available.
170180

181+
.. versionchanged:: next
182+
Added the *max_threads* keyword argument.
183+
171184
.. function:: cancel_dump_traceback_later()
172185

173186
Cancel the last call to :func:`dump_traceback_later`.
@@ -176,11 +189,12 @@ Dumping the tracebacks after a timeout
176189
Dumping the traceback on a user signal
177190
--------------------------------------
178191

179-
.. function:: register(signum, file=sys.stderr, all_threads=True, chain=False)
192+
.. function:: register(signum, file=sys.stderr, all_threads=True, chain=False, *, max_threads=100)
180193

181194
Register a user signal: install a handler for the *signum* signal to dump
182195
the traceback of all threads, or of the current thread if *all_threads* is
183196
``False``, into *file*. Call the previous handler if chain is ``True``.
197+
*max_threads* caps the number of threads dumped.
184198

185199
The *file* must be kept open until the signal is unregistered by
186200
:func:`unregister`: see :ref:`issue with file descriptors <faulthandler-fd>`.
@@ -190,6 +204,9 @@ Dumping the traceback on a user signal
190204
.. versionchanged:: 3.5
191205
Added support for passing file descriptor to this function.
192206

207+
.. versionchanged:: next
208+
Added the *max_threads* keyword argument.
209+
193210
.. function:: unregister(signum)
194211

195212
Unregister a user signal: uninstall the handler of the *signum* signal

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ The :mod:`!functools` module defines the following functions:
468468

469469
Roughly equivalent to::
470470

471-
initial_missing = object()
471+
initial_missing = sentinel('initial_missing')
472472

473473
def reduce(function, iterable, /, initial=initial_missing):
474474
it = iter(iterable)

Doc/library/gc.rst

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,11 @@ The :mod:`!gc` module provides the following functions:
3737

3838
.. function:: collect(generation=2)
3939

40-
Perform a collection. The optional argument *generation*
40+
With no arguments, run a full collection. The optional argument *generation*
4141
may be an integer specifying which generation to collect (from 0 to 2). A
4242
:exc:`ValueError` is raised if the generation number is invalid. The sum of
4343
collected objects and uncollectable objects is returned.
4444

45-
Calling ``gc.collect(0)`` will perform a GC collection on the young generation.
46-
47-
Calling ``gc.collect(1)`` will perform a GC collection on the young generation
48-
and an increment of the old generation.
49-
50-
Calling ``gc.collect(2)`` or ``gc.collect()`` performs a full collection
51-
5245
The free lists maintained for a number of built-in types are cleared
5346
whenever a full collection or collection of the highest generation (2)
5447
is run. Not all items in some free lists may be freed due to the
@@ -60,6 +53,9 @@ The :mod:`!gc` module provides the following functions:
6053
.. versionchanged:: 3.14
6154
``generation=1`` performs an increment of collection.
6255

56+
.. versionchanged:: 3.14.5
57+
``generation=1`` performs collection of the middle generation.
58+
6359

6460
.. function:: set_debug(flags)
6561

@@ -75,20 +71,19 @@ The :mod:`!gc` module provides the following functions:
7571

7672
.. function:: get_objects(generation=None)
7773

78-
7974
Returns a list of all objects tracked by the collector, excluding the list
80-
returned. If *generation* is not ``None``, return only the objects as follows:
81-
82-
* 0: All objects in the young generation
83-
* 1: No objects, as there is no generation 1 (as of Python 3.14)
84-
* 2: All objects in the old generation
75+
returned. If *generation* is not ``None``, return only the objects tracked by
76+
the collector that are in that generation.
8577

8678
.. versionchanged:: 3.8
8779
New *generation* parameter.
8880

8981
.. versionchanged:: 3.14
9082
Generation 1 is removed
9183

84+
.. versionchanged:: 3.14.5
85+
Generation 1 is reintroduced to maintain GC behavior from 3.13.
86+
9287
.. audit-event:: gc.get_objects generation gc.get_objects
9388

9489
.. function:: get_stats()
@@ -124,33 +119,33 @@ The :mod:`!gc` module provides the following functions:
124119
Set the garbage collection thresholds (the collection frequency). Setting
125120
*threshold0* to zero disables collection.
126121

127-
The GC classifies objects into two generations depending on whether they have
128-
survived a collection. New objects are placed in the young generation. If an
129-
object survives a collection it is moved into the old generation.
130-
131-
In order to decide when to run, the collector keeps track of the number of object
122+
The GC classifies objects into three generations depending on how many
123+
collection sweeps they have survived. New objects are placed in the youngest
124+
generation (generation ``0``). If an object survives a collection it is moved
125+
into the next older generation. Since generation ``2`` is the oldest
126+
generation, objects in that generation remain there after a collection. In
127+
order to decide when to run, the collector keeps track of the number object
132128
allocations and deallocations since the last collection. When the number of
133129
allocations minus the number of deallocations exceeds *threshold0*, collection
134-
starts. For each collection, all the objects in the young generation and some
135-
fraction of the old generation is collected.
130+
starts. Initially only generation ``0`` is examined. If generation ``0`` has
131+
been examined more than *threshold1* times since generation ``1`` has been
132+
examined, then generation ``1`` is examined as well.
133+
With the third generation, things are a bit more complicated,
134+
see `Collecting the oldest generation <https://github.com/python/cpython/blob/ff0ef0a54bef26fc507fbf9b7a6009eb7d3f17f5/InternalDocs/garbage_collector.md#collecting-the-oldest-generation>`_ for more information.
136135

137136
In the free-threaded build, the increase in process memory usage is also
138137
checked before running the collector. If the memory usage has not increased
139138
by 10% since the last collection and the net number of object allocations
140139
has not exceeded 40 times *threshold0*, the collection is not run.
141140

142-
The fraction of the old generation that is collected is **inversely** proportional
143-
to *threshold1*. The larger *threshold1* is, the slower objects in the old generation
144-
are collected.
145-
For the default value of 10, 1% of the old generation is scanned during each collection.
146-
147-
*threshold2* is ignored.
148-
149-
See `Garbage collector design <https://devguide.python.org/garbage_collector>`_ for more information.
141+
See `Garbage collector design <https://github.com/python/cpython/blob/3.15/InternalDocs/garbage_collector.md>`_ for more information.
150142

151143
.. versionchanged:: 3.14
152144
*threshold2* is ignored
153145

146+
.. versionchanged:: 3.14.5
147+
*threshold2* is restored to match Python 3.13 behavior.
148+
154149

155150
.. function:: get_count()
156151

Doc/library/http.cookies.rst

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ The character set, :data:`string.ascii_letters`, :data:`string.digits` and
2525
in a cookie name (as :attr:`~Morsel.key`).
2626

2727
.. versionchanged:: 3.3
28-
Allowed '``:``' as a valid cookie name character.
28+
Allowed ':' as a valid cookie name character.
2929

30-
.. versionchanged:: 3.15
31-
Allowed '``"``' as a valid cookie value character.
3230

3331
.. note::
3432

@@ -313,10 +311,3 @@ The following example demonstrates how to use the :mod:`!http.cookies` module.
313311
>>> print(C)
314312
Set-Cookie: number=7
315313
Set-Cookie: string=seven
316-
>>> import json
317-
>>> C = cookies.SimpleCookie()
318-
>>> C.load(f'cookies=7; mixins="{json.dumps({"chips": "dark chocolate"})}"; state=gooey')
319-
>>> print(C)
320-
Set-Cookie: cookies=7
321-
Set-Cookie: mixins="{"chips": "dark chocolate"}"
322-
Set-Cookie: state=gooey

Doc/library/http.server.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ instantiation, of which this module provides three different variants:
390390
This will be ``"SimpleHTTP/" + __version__``, where ``__version__`` is
391391
defined at the module level.
392392

393+
.. attribute:: default_content_type
394+
395+
Specifies the Content-Type header value sent when the MIME type
396+
cannot be guessed from the file extension of the requested URL.
397+
By default, it is set to ``'application/octet-stream'``.
398+
399+
.. versionadded:: next
400+
393401
.. attribute:: extensions_map
394402

395403
A dictionary mapping suffixes into MIME types, contains custom overrides
@@ -528,6 +536,18 @@ The following options are accepted:
528536
529537
.. versionadded:: 3.11
530538

539+
.. option:: --content-type <content_type>
540+
541+
Specifies the default Content-Type HTTP header used when the MIME type
542+
cannot be guessed from the URL's file extension. By default, the server
543+
uses ``'application/octet-stream'``:
544+
545+
.. code-block:: bash
546+
547+
python -m http.server --content-type text/html
548+
549+
.. versionadded:: next
550+
531551
.. option:: --tls-cert
532552

533553
Specifies a TLS certificate chain for HTTPS connections:

Doc/library/pickletools.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Command-line options
7979

8080
A pickle file to read, or ``-`` to indicate reading from standard input.
8181

82+
.. versionadded:: next
83+
Output is in color by default and can be
84+
:ref:`controlled using environment variables <using-on-controlling-color>`.
8285

8386

8487
Programmatic interface

Doc/library/tomllib.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ support writing TOML.
1919
Added TOML 1.1.0 support.
2020
See the :ref:`What's New <whatsnew315-tomllib-1-1-0>` for details.
2121

22+
.. warning::
23+
24+
Be cautious when parsing data from untrusted sources.
25+
A malicious TOML string may cause the decoder to consume considerable
26+
CPU and memory resources.
27+
Limiting the size of data to be parsed is recommended.
2228

2329
.. seealso::
2430

Doc/make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if not defined SPHINXBUILD (
1313
%PYTHON% -c "import sphinx" > nul 2> nul
1414
if errorlevel 1 (
1515
echo Installing sphinx with %PYTHON%
16-
%PYTHON% -m pip install -r pylock.toml
16+
%PYTHON% -m pip install -r requirements.txt
1717
if errorlevel 1 exit /B
1818
)
1919
set SPHINXBUILD=%PYTHON% -c "import sphinx.cmd.build, sys; sys.exit(sphinx.cmd.build.main())"

0 commit comments

Comments
 (0)