Skip to content

Commit 65e79ff

Browse files
committed
Merge branch 'main' into gh-118331-nullify-items
2 parents aa811fe + 4f62189 commit 65e79ff

File tree

107 files changed

+2203
-952
lines changed

Some content is hidden

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

107 files changed

+2203
-952
lines changed

Doc/c-api/intro.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ familiar with writing an extension before attempting to embed Python in a real
3030
application.
3131

3232

33+
Language version compatibility
34+
==============================
35+
36+
Python's C API is compatible with C11 and C++11 versions of C and C++.
37+
38+
This is a lower limit: the C API does not require features from later
39+
C/C++ versions.
40+
You do *not* need to enable your compiler's "c11 mode".
41+
42+
3343
Coding standards
3444
================
3545

Doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
# Minimum version of sphinx required
102102
# Keep this version in sync with ``Doc/requirements.txt``.
103-
needs_sphinx = '8.1.3'
103+
needs_sphinx = '8.2.0'
104104

105105
# Create table of contents entries for domain objects (e.g. functions, classes,
106106
# attributes, etc.). Default is True.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ although there is currently no date scheduled for their removal.
127127

128128
* :class:`typing.Text` (:gh:`92332`).
129129

130+
* The internal class ``typing._UnionGenericAlias`` is no longer used to implement
131+
:class:`typing.Union`. To preserve compatibility with users using this private
132+
class, a compatibility shim will be provided until at least Python 3.17. (Contributed by
133+
Jelle Zijlstra in :gh:`105499`.)
134+
130135
* :class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a value
131136
that is not ``None`` from a test case.
132137

Doc/library/concurrent.futures.rst

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -415,30 +415,6 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
415415
require the *fork* start method for :class:`ProcessPoolExecutor` you must
416416
explicitly pass ``mp_context=multiprocessing.get_context("fork")``.
417417

418-
.. method:: terminate_workers()
419-
420-
Attempt to terminate all living worker processes immediately by calling
421-
:meth:`Process.terminate <multiprocessing.Process.terminate>` on each of them.
422-
Internally, it will also call :meth:`Executor.shutdown` to ensure that all
423-
other resources associated with the executor are freed.
424-
425-
After calling this method the caller should no longer submit tasks to the
426-
executor.
427-
428-
.. versionadded:: next
429-
430-
.. method:: kill_workers()
431-
432-
Attempt to kill all living worker processes immediately by calling
433-
:meth:`Process.kill <multiprocessing.Process.kill>` on each of them.
434-
Internally, it will also call :meth:`Executor.shutdown` to ensure that all
435-
other resources associated with the executor are freed.
436-
437-
After calling this method the caller should no longer submit tasks to the
438-
executor.
439-
440-
.. versionadded:: next
441-
442418
.. _processpoolexecutor-example:
443419

444420
ProcessPoolExecutor Example

Doc/library/functools.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ The :mod:`functools` module defines the following functions:
518518
... for i, elem in enumerate(arg):
519519
... print(i, elem)
520520

521-
:data:`types.UnionType` and :data:`typing.Union` can also be used::
521+
:class:`typing.Union` can also be used::
522522

523523
>>> @fun.register
524524
... def _(arg: int | float, verbose=False):
@@ -654,8 +654,8 @@ The :mod:`functools` module defines the following functions:
654654
The :func:`register` attribute now supports using type annotations.
655655

656656
.. versionchanged:: 3.11
657-
The :func:`register` attribute now supports :data:`types.UnionType`
658-
and :data:`typing.Union` as type annotations.
657+
The :func:`register` attribute now supports
658+
:class:`typing.Union` as a type annotation.
659659

660660

661661
.. class:: singledispatchmethod(func)

Doc/library/pdb.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ access further features, you have to do this yourself:
245245
.. versionadded:: 3.14
246246
Added the *mode* argument.
247247

248+
.. versionchanged:: 3.14
249+
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will
250+
always stop the program at calling frame, ignoring the *skip* pattern (if any).
251+
248252
.. method:: run(statement, globals=None, locals=None)
249253
runeval(expression, globals=None, locals=None)
250254
runcall(function, *args, **kwds)

Doc/library/stdtypes.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5364,7 +5364,7 @@ Union Type
53645364
A union object holds the value of the ``|`` (bitwise or) operation on
53655365
multiple :ref:`type objects <bltin-type-objects>`. These types are intended
53665366
primarily for :term:`type annotations <annotation>`. The union type expression
5367-
enables cleaner type hinting syntax compared to :data:`typing.Union`.
5367+
enables cleaner type hinting syntax compared to subscripting :class:`typing.Union`.
53685368

53695369
.. describe:: X | Y | ...
53705370

@@ -5400,9 +5400,10 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
54005400

54015401
int | str == str | int
54025402

5403-
* It is compatible with :data:`typing.Union`::
5403+
* It creates instances of :class:`typing.Union`::
54045404

54055405
int | str == typing.Union[int, str]
5406+
type(int | str) is typing.Union
54065407

54075408
* Optional types can be spelled as a union with ``None``::
54085409

@@ -5428,16 +5429,15 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
54285429
TypeError: isinstance() argument 2 cannot be a parameterized generic
54295430

54305431
The user-exposed type for the union object can be accessed from
5431-
:data:`types.UnionType` and used for :func:`isinstance` checks. An object cannot be
5432-
instantiated from the type::
5432+
:class:`typing.Union` and used for :func:`isinstance` checks::
54335433

5434-
>>> import types
5435-
>>> isinstance(int | str, types.UnionType)
5434+
>>> import typing
5435+
>>> isinstance(int | str, typing.Union)
54365436
True
5437-
>>> types.UnionType()
5437+
>>> typing.Union()
54385438
Traceback (most recent call last):
54395439
File "<stdin>", line 1, in <module>
5440-
TypeError: cannot create 'types.UnionType' instances
5440+
TypeError: cannot create 'typing.Union' instances
54415441

54425442
.. note::
54435443
The :meth:`!__or__` method for type objects was added to support the syntax
@@ -5464,6 +5464,11 @@ instantiated from the type::
54645464

54655465
.. versionadded:: 3.10
54665466

5467+
.. versionchanged:: 3.14
5468+
5469+
Union objects are now instances of :class:`typing.Union`. Previously, they were instances
5470+
of :class:`types.UnionType`, which remains an alias for :class:`typing.Union`.
5471+
54675472

54685473
.. _typesother:
54695474

Doc/library/types.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ Standard names are defined for the following types:
314314

315315
.. versionadded:: 3.10
316316

317+
.. versionchanged:: 3.14
318+
319+
This is now an alias for :class:`typing.Union`.
320+
317321
.. class:: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)
318322

319323
The type of traceback objects such as found in ``sys.exception().__traceback__``.

Doc/library/typing.rst

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ provides backports of these new features to older versions of Python.
5353
should broadly apply to most Python type checkers. (Some parts may still
5454
be specific to mypy.)
5555

56-
`"Static Typing with Python" <https://typing.readthedocs.io/en/latest/>`_
56+
`"Static Typing with Python" <https://typing.python.org/en/latest/>`_
5757
Type-checker-agnostic documentation written by the community detailing
5858
type system features, useful typing related tools and typing best
5959
practices.
@@ -64,7 +64,7 @@ Specification for the Python Type System
6464
========================================
6565

6666
The canonical, up-to-date specification of the Python type system can be
67-
found at `"Specification for the Python type system" <https://typing.readthedocs.io/en/latest/spec/index.html>`_.
67+
found at `"Specification for the Python type system" <https://typing.python.org/en/latest/spec/index.html>`_.
6868

6969
.. _type-aliases:
7070

@@ -1086,7 +1086,7 @@ Special forms
10861086
These can be used as types in annotations. They all support subscription using
10871087
``[]``, but each has a unique syntax.
10881088

1089-
.. data:: Union
1089+
.. class:: Union
10901090

10911091
Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or Y.
10921092

@@ -1121,6 +1121,14 @@ These can be used as types in annotations. They all support subscription using
11211121
Unions can now be written as ``X | Y``. See
11221122
:ref:`union type expressions<types-union>`.
11231123

1124+
.. versionchanged:: 3.14
1125+
:class:`types.UnionType` is now an alias for :class:`Union`, and both
1126+
``Union[int, str]`` and ``int | str`` create instances of the same class.
1127+
To check whether an object is a ``Union`` at runtime, use
1128+
``isinstance(obj, Union)``. For compatibility with earlier versions of
1129+
Python, use
1130+
``get_origin(obj) is typing.Union or get_origin(obj) is types.UnionType``.
1131+
11241132
.. data:: Optional
11251133

11261134
``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``).
@@ -2292,6 +2300,20 @@ without the dedicated syntax, as documented below.
22922300

22932301
.. versionadded:: 3.14
22942302

2303+
.. rubric:: Unpacking
2304+
2305+
Type aliases support star unpacking using the ``*Alias`` syntax.
2306+
This is equivalent to using ``Unpack[Alias]`` directly:
2307+
2308+
.. doctest::
2309+
2310+
>>> type Alias = tuple[int, str]
2311+
>>> type Unpacked = tuple[bool, *Alias]
2312+
>>> Unpacked.__value__
2313+
tuple[bool, typing.Unpack[Alias]]
2314+
2315+
.. versionadded:: next
2316+
22952317

22962318
Other special directives
22972319
""""""""""""""""""""""""
@@ -2551,15 +2573,20 @@ types.
25512573

25522574
This functional syntax allows defining keys which are not valid
25532575
:ref:`identifiers <identifiers>`, for example because they are
2554-
keywords or contain hyphens::
2576+
keywords or contain hyphens, or when key names must not be
2577+
:ref:`mangled <private-name-mangling>` like regular private names::
25552578

25562579
# raises SyntaxError
25572580
class Point2D(TypedDict):
25582581
in: int # 'in' is a keyword
25592582
x-y: int # name with hyphens
25602583

2584+
class Definition(TypedDict):
2585+
__schema: str # mangled to `_Definition__schema`
2586+
25612587
# OK, functional syntax
25622588
Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})
2589+
Definition = TypedDict('Definition', {'__schema': str}) # not mangled
25632590

25642591
By default, all keys must be present in a ``TypedDict``. It is possible to
25652592
mark individual keys as non-required using :data:`NotRequired`::
@@ -2885,7 +2912,7 @@ Functions and decorators
28852912

28862913
.. seealso::
28872914
`Unreachable Code and Exhaustiveness Checking
2888-
<https://typing.readthedocs.io/en/latest/guides/unreachable.html>`__ has more
2915+
<https://typing.python.org/en/latest/guides/unreachable.html>`__ has more
28892916
information about exhaustiveness checking with static typing.
28902917

28912918
.. versionadded:: 3.11

Doc/library/uuid.rst

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
--------------
1212

1313
This module provides immutable :class:`UUID` objects (the :class:`UUID` class)
14-
and the functions :func:`uuid1`, :func:`uuid3`, :func:`uuid4`, :func:`uuid5`,
15-
:func:`uuid6`, and :func:`uuid8` for generating version 1, 3, 4, 5, 6,
16-
and 8 UUIDs as specified in :rfc:`9562` (which supersedes :rfc:`4122`).
14+
and :ref:`functions <uuid-factory-functions>` for generating UUIDs corresponding
15+
to a specific UUID version as specified in :rfc:`9562` (which supersedes :rfc:`4122`),
16+
for example, :func:`uuid1` for UUID version 1, :func:`uuid3` for UUID version 3, and so on.
17+
Note that UUID version 2 is deliberately omitted as it is outside the scope of the RFC.
1718

1819
If all you want is a unique ID, you should probably call :func:`uuid1` or
1920
:func:`uuid4`. Note that :func:`uuid1` may compromise privacy since it creates
@@ -154,7 +155,7 @@ which relays any information about the UUID's safety, using this enumeration:
154155
:const:`RFC_4122`).
155156

156157
.. versionchanged:: next
157-
Added UUID versions 6 and 8.
158+
Added UUID versions 6, 7 and 8.
158159

159160

160161
.. attribute:: UUID.is_safe
@@ -185,6 +186,8 @@ The :mod:`uuid` module defines the following functions:
185186
globally unique, while the latter are not.
186187

187188

189+
.. _uuid-factory-functions:
190+
188191
.. function:: uuid1(node=None, clock_seq=None)
189192

190193
Generate a UUID from a host ID, sequence number, and the current time. If *node*
@@ -228,6 +231,18 @@ The :mod:`uuid` module defines the following functions:
228231
.. versionadded:: next
229232

230233

234+
.. function:: uuid7()
235+
236+
Generate a time-based UUID according to
237+
:rfc:`RFC 9562, §5.7 <9562#section-5.7>`.
238+
239+
For portability across platforms lacking sub-millisecond precision, UUIDs
240+
produced by this function embed a 48-bit timestamp and use a 42-bit counter
241+
to guarantee monotonicity within a millisecond.
242+
243+
.. versionadded:: next
244+
245+
231246
.. function:: uuid8(a=None, b=None, c=None)
232247

233248
Generate a pseudo-random UUID according to
@@ -330,7 +345,7 @@ The :mod:`uuid` module can be executed as a script from the command line.
330345

331346
.. code-block:: sh
332347
333-
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid6,uuid8}] [-n NAMESPACE] [-N NAME]
348+
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid6,uuid7,uuid8}] [-n NAMESPACE] [-N NAME]
334349
335350
The following options are accepted:
336351

@@ -347,7 +362,7 @@ The following options are accepted:
347362
is used.
348363

349364
.. versionchanged:: next
350-
Allow generating UUID versions 6 and 8.
365+
Allow generating UUID versions 6, 7 and 8.
351366

352367
.. option:: -n <namespace>
353368
--namespace <namespace>

0 commit comments

Comments
 (0)