Skip to content

Commit 847cba1

Browse files
committed
Merge remote-tracking branch 'origin/main' into ft-gc-threshold-fix-main
2 parents 057f862 + 68fe899 commit 847cba1

145 files changed

Lines changed: 5919 additions & 1466 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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,13 @@ jobs:
278278
# unsupported as it most resembles other 1.1.1-work-a-like ssl APIs
279279
# supported by important vendors such as AWS-LC.
280280
- { name: openssl, version: 1.1.1w }
281-
- { name: openssl, version: 3.0.19 }
282-
- { name: openssl, version: 3.3.6 }
283-
- { name: openssl, version: 3.4.4 }
284-
- { name: openssl, version: 3.5.5 }
285-
- { name: openssl, version: 3.6.1 }
281+
- { name: openssl, version: 3.0.20 }
282+
- { name: openssl, version: 3.3.7 }
283+
- { name: openssl, version: 3.4.5 }
284+
- { name: openssl, version: 3.5.6 }
285+
- { name: openssl, version: 3.6.2 }
286286
## AWS-LC
287-
- { name: aws-lc, version: 1.68.0 }
287+
- { name: aws-lc, version: 1.72.1 }
288288
env:
289289
SSLLIB_VER: ${{ matrix.ssllib.version }}
290290
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -398,7 +398,7 @@ jobs:
398398
needs: build-context
399399
if: needs.build-context.outputs.run-ubuntu == 'true'
400400
env:
401-
OPENSSL_VER: 3.5.5
401+
OPENSSL_VER: 3.5.6
402402
PYTHONSTRICTEXTENSIONBUILD: 1
403403
steps:
404404
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -506,7 +506,7 @@ jobs:
506506
matrix:
507507
os: [ubuntu-24.04]
508508
env:
509-
OPENSSL_VER: 3.5.5
509+
OPENSSL_VER: 3.5.6
510510
PYTHONSTRICTEXTENSIONBUILD: 1
511511
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
512512
steps:

.github/workflows/reusable-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
runs-on: ${{ inputs.os }}
3636
timeout-minutes: 60
3737
env:
38-
OPENSSL_VER: 3.5.5
38+
OPENSSL_VER: 3.5.6
3939
PYTHONSTRICTEXTENSIONBUILD: 1
4040
TERM: linux
4141
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Tools/unicode/data/
140140
/.ccache
141141
/cross-build*/
142142
/jit_stencils*.h
143+
/jit_unwind_info*.h
143144
/platform
144145
/profile-clean-stamp
145146
/profile-run-stamp

Doc/c-api/perfmaps.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Note that holding an :term:`attached thread state` is not required for these API
3131
or ``-2`` on failure to create a lock. Check ``errno`` for more information
3232
about the cause of a failure.
3333

34-
.. c:function:: int PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name)
34+
.. c:function:: int PyUnstable_WritePerfMapEntry(const void *code_addr, size_t code_size, const char *entry_name)
3535
3636
Write one single entry to the ``/tmp/perf-$pid.map`` file. This function is
3737
thread safe. Here is what an example entry looks like::

Doc/deprecations/pending-removal-in-3.18.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ Pending removal in Python 3.18
1010
specifier ``'N'``, which is only supported in the :mod:`!decimal` module's
1111
C implementation, has been deprecated since Python 3.13.
1212
(Contributed by Serhiy Storchaka in :gh:`89902`.)
13+
14+
* Deprecations defined by :pep:`829`:
15+
16+
* ``import`` lines in :file:`{name}.pth` files are silently ignored.
17+
18+
(Contributed by Barry Warsaw in :gh:`148641`.)

Doc/deprecations/pending-removal-in-3.20.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,18 @@ Pending removal in Python 3.20
3838
- :mod:`zlib`
3939

4040
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)
41+
42+
* Deprecations defined by :pep:`829`:
43+
44+
* Warnings are produced for ``import`` lines found in :file:`{name}.pth`
45+
files.
46+
47+
* :file:`{name}.pth` files are no longer decoded in the locale encoding by
48+
default. They **MUST** be encoded in ``utf-8-sig``.
49+
50+
(Contributed by Barry Warsaw in :gh:`148641`.)
51+
52+
* :mod:`ast`:
53+
54+
* Creating instances of abstract AST nodes (such as :class:`ast.AST`
55+
or :class:`!ast.expr`) is deprecated and will raise an error in Python 3.20.

Doc/glossary.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ Glossary
3939
ABCs with the :mod:`abc` module.
4040

4141
annotate function
42-
A function that can be called to retrieve the :term:`annotations <annotation>`
43-
of an object. This function is accessible as the :attr:`~object.__annotate__`
44-
attribute of functions, classes, and modules. Annotate functions are a
45-
subset of :term:`evaluate functions <evaluate function>`.
42+
A callable that can be called to retrieve the :term:`annotations <annotation>` of
43+
an object. Annotate functions are usually :term:`functions <function>`,
44+
automatically generated as the :attr:`~object.__annotate__` attribute of functions,
45+
classes, and modules. Annotate functions are a subset of
46+
:term:`evaluate functions <evaluate function>`.
4647

4748
annotation
4849
A label associated with a variable, a class

Doc/library/annotationlib.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,81 @@ annotations from the class and puts them in a separate attribute:
510510
return typ
511511
512512
513+
Creating a custom callable annotate function
514+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
515+
516+
Custom :term:`annotate functions <annotate function>` may be literal functions like those
517+
automatically generated for functions, classes, and modules. Or, they may wish to utilise
518+
the encapsulation provided by classes, in which case any :term:`callable` can be used as
519+
an :term:`annotate function`.
520+
521+
To provide the :attr:`~Format.VALUE`, :attr:`~Format.STRING`, or
522+
:attr:`~Format.FORWARDREF` formats directly, an :term:`annotate function` must provide
523+
the following attribute:
524+
525+
* A callable ``__call__`` with signature ``__call__(format, /) -> dict``, that does not
526+
raise a :exc:`NotImplementedError` when called with a supported format.
527+
528+
To provide the :attr:`~Format.VALUE_WITH_FAKE_GLOBALS` format, which is used to
529+
automatically generate :attr:`~Format.STRING` or :attr:`~Format.FORWARDREF` if they are
530+
not supported directly, :term:`annotate functions <annotate function>` must provide the
531+
following attributes:
532+
533+
* A callable ``__call__`` with signature ``__call__(format, /) -> dict``, that does not
534+
raise a :exc:`NotImplementedError` when called with
535+
:attr:`~Format.VALUE_WITH_FAKE_GLOBALS`.
536+
* A :ref:`code object <code-objects>` ``__code__`` containing the compiled code for the
537+
annotate function.
538+
* Optional: A tuple of the function's positional defaults ``__kwdefaults__``, if the
539+
function represented by ``__code__`` uses any positional defaults.
540+
* Optional: A dict of the function's keyword defaults ``__defaults__``, if the function
541+
represented by ``__code__`` uses any keyword defaults.
542+
* Optional: All other :ref:`function attributes <inspect-types>`.
543+
544+
.. code-block:: python
545+
546+
class Annotate:
547+
called_formats = []
548+
549+
def __call__(self, format=None, /, *, _self=None):
550+
# When called with fake globals, `_self` will be the
551+
# actual self value, and `self` will be the format.
552+
if _self is not None:
553+
self, format = _self, self
554+
555+
self.called_formats.append(format)
556+
if format <= 2: # VALUE or VALUE_WITH_FAKE_GLOBALS
557+
return {"x": MyType}
558+
raise NotImplementedError
559+
560+
__code__ = __call__.__code__
561+
__defaults__ = (None,)
562+
__kwdefaults__ = property(lambda self: dict(_self=self))
563+
564+
__globals__ = {}
565+
__builtins__ = {}
566+
__closure__ = None
567+
568+
This can then be called with:
569+
570+
.. code-block:: pycon
571+
572+
>>> from annotationlib import call_annotate_function, Format
573+
>>> call_annotate_function(Annotate(), format=Format.STRING)
574+
{'x': 'MyType'}
575+
576+
Or used as the annotate function for an object:
577+
578+
.. code-block:: pycon
579+
580+
>>> from annotationlib import get_annotations, Format
581+
>>> class C:
582+
... pass
583+
>>> C.__annotate__ = Annotate()
584+
>>> get_annotations(Annotate(), format=Format.STRING)
585+
{'x': 'MyType'}
586+
587+
513588
Limitations of the ``STRING`` format
514589
------------------------------------
515590

Doc/library/ast.rst

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Node classes
4242

4343
.. class:: AST
4444

45-
This is the base of all AST node classes. The actual node classes are
45+
This is the abstract base of all AST node classes. The actual node classes are
4646
derived from the :file:`Parser/Python.asdl` file, which is reproduced
4747
:ref:`above <abstract-grammar>`. They are defined in the :mod:`!_ast` C
4848
module and re-exported in :mod:`!ast`.
@@ -168,6 +168,15 @@ Node classes
168168
arguments that were set as attributes of the AST node, even if they did not
169169
match any of the fields of the AST node. These cases now raise a :exc:`TypeError`.
170170

171+
.. deprecated-removed:: next 3.20
172+
173+
In the :ref:`grammar above <abstract-grammar>`, the AST node classes that
174+
correspond to production rules with variants (aka "sums") are abstract
175+
classes. Previous versions of Python allowed for the creation of direct
176+
instances of these abstract node classes. This behavior is deprecated and
177+
will be removed in Python 3.20.
178+
179+
171180
.. note::
172181
The descriptions of the specific node classes displayed here
173182
were initially adapted from the fantastic `Green Tree
@@ -271,18 +280,25 @@ Root nodes
271280
Literals
272281
^^^^^^^^
273282

274-
.. class:: Constant(value)
283+
.. class:: Constant(value, kind)
275284

276285
A constant value. The ``value`` attribute of the ``Constant`` literal contains the
277286
Python object it represents. The values represented can be instances of :class:`str`,
278287
:class:`bytes`, :class:`int`, :class:`float`, :class:`complex`, and :class:`bool`,
279288
and the constants :data:`None` and :data:`Ellipsis`.
280289

290+
The ``kind`` attribute is an optional string. For string literals with a
291+
``u`` prefix, ``kind`` is set to ``'u'``. For all other
292+
constants, ``kind`` is ``None``.
293+
281294
.. doctest::
282295

283296
>>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
284297
Expression(
285298
body=Constant(value=123))
299+
>>> print(ast.dump(ast.parse("u'hello'", mode='eval'), indent=4))
300+
Expression(
301+
body=Constant(value='hello', kind='u'))
286302

287303

288304
.. class:: FormattedValue(value, conversion, format_spec)
@@ -2536,6 +2552,20 @@ and classes for traversing abstract syntax trees:
25362552
Added the *color* parameter.
25372553

25382554

2555+
.. function:: compare(a, b, /, *, compare_attributes=False)
2556+
2557+
Recursively compares two ASTs.
2558+
2559+
*compare_attributes* affects whether AST attributes are considered
2560+
in the comparison. If *compare_attributes* is ``False`` (default), then
2561+
attributes are ignored. Otherwise they must all be equal. This
2562+
option is useful to check whether the ASTs are structurally equal but
2563+
differ in whitespace or similar details. Attributes include line numbers
2564+
and column offsets.
2565+
2566+
.. versionadded:: 3.14
2567+
2568+
25392569
.. _ast-compiler-flags:
25402570

25412571
Compiler flags
@@ -2571,20 +2601,6 @@ effects on the compilation of a program:
25712601
.. versionadded:: 3.8
25722602

25732603

2574-
.. function:: compare(a, b, /, *, compare_attributes=False)
2575-
2576-
Recursively compares two ASTs.
2577-
2578-
*compare_attributes* affects whether AST attributes are considered
2579-
in the comparison. If *compare_attributes* is ``False`` (default), then
2580-
attributes are ignored. Otherwise they must all be equal. This
2581-
option is useful to check whether the ASTs are structurally equal but
2582-
differ in whitespace or similar details. Attributes include line numbers
2583-
and column offsets.
2584-
2585-
.. versionadded:: 3.14
2586-
2587-
25882604
.. _ast-cli:
25892605

25902606
Command-line usage

Doc/library/http.server.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ instantiation, of which this module provides three different variants:
366366
delays, it now always returns the IP address.
367367

368368

369-
.. class:: SimpleHTTPRequestHandler(request, client_address, server, directory=None)
369+
.. class:: SimpleHTTPRequestHandler(request, client_address, server, \
370+
*, directory=None, extra_response_headers=None)
370371
371372
This class serves files from the directory *directory* and below,
372373
or the current directory if *directory* is not provided, directly
@@ -378,6 +379,9 @@ instantiation, of which this module provides three different variants:
378379
.. versionchanged:: 3.9
379380
The *directory* parameter accepts a :term:`path-like object`.
380381

382+
.. versionchanged:: next
383+
Added *extra_response_headers* parameter.
384+
381385
A lot of the work, such as parsing the request, is done by the base class
382386
:class:`BaseHTTPRequestHandler`. This class implements the :func:`do_GET`
383387
and :func:`do_HEAD` functions.
@@ -408,6 +412,15 @@ instantiation, of which this module provides three different variants:
408412
This dictionary is no longer filled with the default system mappings,
409413
but only contains overrides.
410414

415+
.. attribute:: extra_response_headers
416+
417+
A sequence of ``(name, value)`` pairs containing user-defined extra HTTP
418+
response headers to add to each successful HTTP status 200 response. These
419+
headers are not included in other status code responses.
420+
421+
Headers that the server sends automatically such as ``Content-Type``
422+
will not be overwritten by :attr:`!extra_response_headers`.
423+
411424
The :class:`SimpleHTTPRequestHandler` class defines the following methods:
412425

413426
.. method:: do_HEAD()
@@ -440,6 +453,9 @@ instantiation, of which this module provides three different variants:
440453
followed by a ``'Content-Length:'`` header with the file's size and a
441454
``'Last-Modified:'`` header with the file's modification time.
442455

456+
The instance attribute :attr:`extra_response_headers` is a sequence of
457+
``(name, value)`` pairs containing user-defined extra response headers.
458+
443459
Then follows a blank line signifying the end of the headers, and then the
444460
contents of the file are output.
445461

@@ -581,6 +597,15 @@ The following options are accepted:
581597

582598
.. versionadded:: 3.14
583599

600+
.. option:: -H, --header <header> <value>
601+
602+
Specify an additional extra HTTP Response Header to send on successful HTTP
603+
200 responses. Can be used multiple times to send additional custom response
604+
headers. Headers that are sent automatically by the server (for instance
605+
Content-Type) will not be overwritten by the server.
606+
607+
.. versionadded:: next
608+
584609

585610
.. _http.server-security:
586611

0 commit comments

Comments
 (0)