New modules
===========
-* :mod:`annotationlib`: For introspecting :term:`annotations <annotation>`.
- See :pep:`749` for more details.
+* :mod:`annotationlib`:
+ For introspecting :term:`annotations <annotation>`.
+ See :ref:`PEP 749 <whatsnew314-pep649>` for more details.
(Contributed by Jelle Zijlstra in :gh:`119180`.)
+* :mod:`compression` (including :mod:`compression.zstd`):
+ A package for compression-related modules,
+ including a new module to support the Zstandard compression format.
+ See :ref:`PEP 784 <whatsnew314-pep784>` for more details.
+ (Contributed by Emma Harper Smith, Adam Turner, Gregory P. Smith, Tomas Roun,
+ Victor Stinner, and Rogdham in :gh:`132983`.)
+
+* :mod:`concurrent.interpreters`:
+ Support for multiple interpreters in the standard library.
+ See :ref:`PEP 734 <whatsnew314-pep734>` for more details.
+ (Contributed by Eric Snow in :gh:`134939`.)
+
+* :mod:`string.templatelib`:
+ Support for template string literals (t-strings).
+ See :ref:`PEP 750 <whatsnew314-pep750>` for more details.
+ (Contributed by Jim Baker, Guido van Rossum, Paul Everitt, Koudai Aono,
+ Lysandros Nikolaou, Dave Peck, Adam Turner, Jelle Zijlstra, Bénédikt Tran,
+ and Pablo Galindo Salgado in :gh:`132661`.)
+
Improved modules
================
and subparser names if mistyped by the user.
(Contributed by Savannah Ostrowski in :gh:`124456`.)
- .. _whatsnew314-color-argparse:
+.. _whatsnew314-color-argparse:
* Enable color for help text, which can be disabled with the optional *color*
parameter to :class:`argparse.ArgumentParser`.
ast
---
-* Add :func:`ast.compare` for comparing two ASTs.
+* Add :func:`~ast.compare`, a function for comparing two ASTs.
(Contributed by Batuhan Taskaya and Jeremy Hylton in :gh:`60191`.)
* Add support for :func:`copy.replace` for AST nodes.
* Docstrings are now removed from an optimized AST in optimization level 2.
(Contributed by Irit Katriel in :gh:`123958`.)
-* The ``repr()`` output for AST nodes now includes more information.
+* The :func:`repr` output for AST nodes now includes more information.
(Contributed by Tomas Roun in :gh:`116022`.)
-* :func:`ast.parse`, when called with an AST as input, now always verifies
- that the root node type is appropriate.
+* When called with an AST as input, the :func:`~ast.parse` function
+ now always verifies that the root node type is appropriate.
(Contributed by Irit Katriel in :gh:`130139`.)
-* Add new ``--feature-version``, ``--optimize``, ``--show-empty`` options to
- the command-line interface.
+* Add new options to the command-line interface:
+ :option:`--feature-version <ast --feature-version>`,
+ :option:`--optimize <ast --optimize>`, and
+ :option:`--show-empty <ast --show-empty>`.
(Contributed by Semyon Moroz in :gh:`133367`.)
:meth:`asyncio.create_task`,
:meth:`asyncio.loop.create_task`,
:meth:`asyncio.TaskGroup.create_task`.
+
(Contributed by Thomas Grainger in :gh:`128307`.)
* There are two new utility functions for
introspecting and printing a program's call graph:
:func:`~asyncio.capture_call_graph` and :func:`~asyncio.print_call_graph`.
+ See :ref:`Asyncio introspection capabilities
+ <whatsnew314-asyncio-introspection>` for more details.
(Contributed by Yury Selivanov, Pablo Galindo Salgado, and Łukasz Langa
in :gh:`91048`.)
- .. _whatsnew314-color-calendar:
-
calendar
--------
+.. _whatsnew314-color-calendar:
+
* By default, today's date is highlighted in color in :mod:`calendar`'s
:ref:`command-line <calendar-cli>` text output.
This can be controlled by :ref:`environment variables
.. _whatsnew314-concurrent-futures-interp-pool:
-* Add :class:`~concurrent.futures.InterpreterPoolExecutor`,
- which exposes "subinterpreters" (multiple Python interpreters in the
- same process) to Python code. This is separate from the proposed API
- in :pep:`734`.
+* Add a new executor class, :class:`~concurrent.futures.InterpreterPoolExecutor`,
+ which exposes multiple Python interpreters in the same process
+ ('subinterpreters') to Python code.
+ This uses a pool of independent Python interpreters to execute calls
+ asynchronously.
+
+ This is separate from the new :mod:`~concurrent.interpreters` module
+ introduced by :ref:`PEP 734 <whatsnew314-pep734>`.
(Contributed by Eric Snow in :gh:`124548`.)
.. _whatsnew314-concurrent-futures-start-method:
(Contributed by Gregory P. Smith in :gh:`84559`.)
-* Add :meth:`concurrent.futures.ProcessPoolExecutor.terminate_workers` and
- :meth:`concurrent.futures.ProcessPoolExecutor.kill_workers` as
- ways to terminate or kill all living worker processes in the given pool.
+* Add two new methods to :class:`~concurrent.futures.ProcessPoolExecutor`,
+ :meth:`~concurrent.futures.ProcessPoolExecutor.terminate_workers`
+ and :meth:`~concurrent.futures.ProcessPoolExecutor.kill_workers`,
+ as ways to terminate or kill all living worker processes in the given pool.
(Contributed by Charles Machalow in :gh:`130849`.)
-* Add the optional ``buffersize`` parameter to
- :meth:`concurrent.futures.Executor.map` to limit the number of submitted
+* Add the optional *buffersize* parameter to :meth:`Executor.map
+ <concurrent.futures.Executor.map>` to limit the number of submitted
tasks whose results have not yet been yielded. If the buffer is full,
iteration over the *iterables* pauses until a result is yielded from the
buffer.
(Contributed by Enzo Bonnal and Josh Rosenberg in :gh:`74028`.)
+
configparser
------------
-* Security fix: will no longer write config files it cannot read. Attempting
- to :meth:`configparser.ConfigParser.write` keys containing delimiters or
- beginning with the section header pattern will raise a
- :class:`configparser.InvalidWriteError`.
+* :mod:`!configparser` will no longer write config files it cannot read,
+ to improve security.
+ Attempting to :meth:`~configparser.ConfigParser.write` keys containing
+ delimiters or beginning with the section header pattern will raise an
+ :class:`~configparser.InvalidWriteError`.
(Contributed by Jacob Lincoln in :gh:`129270`.)
+
contextvars
-----------
-* Support context manager protocol by :class:`contextvars.Token`.
+* Support the :term:`context manager` protocol
+ for :class:`~contextvars.Token` objects.
(Contributed by Andrew Svetlov in :gh:`129889`.)
------
* The layout of :ref:`bit fields <ctypes-bit-fields-in-structures-unions>`
- in :class:`~ctypes.Structure` and :class:`~ctypes.Union`
- now matches platform defaults (GCC/Clang or MSVC) more closely.
+ in :class:`~ctypes.Structure` and :class:`~ctypes.Union` objects
+ is now a closer match to platform defaults (GCC/Clang or MSVC).
In particular, fields no longer overlap.
(Contributed by Matthias Görgens in :gh:`97702`.)
* On Windows, the :func:`~ctypes.CopyComPointer` function is now public.
(Contributed by Jun Komoda in :gh:`127275`.)
-* :func:`ctypes.memoryview_at` now exists to create a
+* Add :func:`~ctypes.memoryview_at`, a function to create a
:class:`memoryview` object that refers to the supplied pointer and
length. This works like :func:`ctypes.string_at` except it avoids a
buffer copy, and is typically useful when implementing pure Python
(Contributed by Rian Hunter in :gh:`112018`.)
* Complex types, :class:`~ctypes.c_float_complex`,
- :class:`~ctypes.c_double_complex` and :class:`~ctypes.c_longdouble_complex`,
+ :class:`~ctypes.c_double_complex`, and :class:`~ctypes.c_longdouble_complex`,
are now available if both the compiler and the ``libffi`` library support
complex C types.
(Contributed by Sergey B Kirpichev in :gh:`61103`.)
(Contributed by Brian Ward in :gh:`119349`.)
* Move :func:`ctypes.POINTER` types cache from a global internal cache
- (``_pointer_type_cache``) to the :attr:`ctypes._CData.__pointer_type__`
- attribute of the corresponding :mod:`ctypes` types.
+ (``_pointer_type_cache``) to the :attr:`_CData.__pointer_type__
+ <ctypes._CData.__pointer_type__>` attribute of the corresponding
+ :mod:`!ctypes` types.
This will stop the cache from growing without limits in some situations.
(Contributed by Sergey Miryanov in :gh:`100926`.)
-* The :class:`ctypes.py_object` type now supports subscription,
+* The :class:`~ctypes.py_object` type now supports subscription,
making it a :term:`generic type`.
(Contributed by Brian Schubert in :gh:`132168`.)
-* :mod:`ctypes` now supports :term:`free-threading builds <free threading>`.
+* :mod:`!ctypes` now supports :term:`free-threading builds <free threading>`.
(Contributed by Kumar Aditya and Peter Bierma in :gh:`127945`.)
+
curses
------
* Add the :func:`~curses.assume_default_colors` function,
a refinement of the :func:`~curses.use_default_colors` function which
- allows to change the color pair ``0``.
+ allows changing the color pair ``0``.
(Contributed by Serhiy Storchaka in :gh:`133139`.)
+
datetime
--------
-* Add :meth:`datetime.time.strptime` and :meth:`datetime.date.strptime`.
+* Add the :meth:`~datetime.date.strptime` method to the
+ :class:`datetime.date` and :class:`datetime.time` classes.
(Contributed by Wannes Boeykens in :gh:`41431`.)
+
decimal
-------
-* Add alternative :class:`~decimal.Decimal` constructor
- :meth:`Decimal.from_number() <decimal.Decimal.from_number>`.
+* Add :meth:`.Decimal.from_number` as an alternative constructor for
+ :class:`~decimal.Decimal`.
(Contributed by Serhiy Storchaka in :gh:`121798`.)
-* Expose :func:`decimal.IEEEContext` to support creation of contexts
+* Expose :func:`~decimal.IEEEContext` to support creation of contexts
corresponding to the IEEE 754 (2008) decimal interchange formats.
(Contributed by Sergey B Kirpichev in :gh:`53032`.)
+
difflib
-------
* Comparison pages with highlighted changes generated by the
- :class:`difflib.HtmlDiff` class now support dark mode.
+ :class:`~difflib.HtmlDiff` class now support 'dark mode'.
(Contributed by Jiahao Li in :gh:`129939`.)
+
dis
---
errno
-----
-* Add :data:`errno.EHWPOISON` error code.
+* Add the :data:`~errno.EHWPOISON` error code constant.
(Contributed by James Roy in :gh:`126585`.)
------------
* Add support for printing the C stack trace on systems that
- :ref:`support it <c-stack-compatibility>` via :func:`faulthandler.dump_c_stack`
- or via the *c_stack* argument in :func:`faulthandler.enable`.
+ :ref:`support it <c-stack-compatibility>` via the new
+ :func:`~faulthandler.dump_c_stack` function or via the *c_stack* argument
+ in :func:`faulthandler.enable`.
(Contributed by Peter Bierma in :gh:`127604`.)
fnmatch
-------
-* Added :func:`fnmatch.filterfalse` for excluding names matching a pattern.
+* Add :func:`~fnmatch.filterfalse`, a function to reject names
+ matching a given pattern.
(Contributed by Bénédikt Tran in :gh:`74598`.)
fractions
---------
-* Add support for converting any objects that have the
- :meth:`!as_integer_ratio` method to a :class:`~fractions.Fraction`.
+* A :class:`~fractions.Fraction` object may now be constructed from any
+ object with the :meth:`!as_integer_ratio` method.
(Contributed by Serhiy Storchaka in :gh:`82017`.)
-* Add alternative :class:`~fractions.Fraction` constructor
- :meth:`Fraction.from_number() <fractions.Fraction.from_number>`.
+* Add :meth:`.Fraction.from_number` as an alternative constructor for
+ :class:`~fractions.Fraction`.
(Contributed by Serhiy Storchaka in :gh:`121797`.)
functools
---------
-* Add support to :func:`functools.partial` and
- :func:`functools.partialmethod` for :data:`functools.Placeholder` sentinels
- to reserve a place for positional arguments.
+* Add the :data:`~functools.Placeholder` sentinel.
+ This may be used with the :func:`~functools.partial`
+ or :func:`~functools.partialmethod` functions to reserve a place
+ for positional arguments in the returned :ref:`partial object
+ <partial-objects>`.
(Contributed by Dominykas Grigonis in :gh:`119127`.)
-* Allow the *initial* parameter of :func:`functools.reduce` to be passed
+* Allow the *initial* parameter of :func:`~functools.reduce` to be passed
as a keyword argument.
(Contributed by Sayandip Dutta in :gh:`125916`.)
getpass
-------
-* Support keyboard feedback by :func:`getpass.getpass` via the keyword-only
- optional argument ``echo_char``. Placeholder characters are rendered whenever
- a character is entered, and removed when a character is deleted.
+* Support keyboard feedback in the :func:`~getpass.getpass` function via
+ the keyword-only optional argument *echo_char*.
+ Placeholder characters are rendered whenever a character is entered,
+ and removed when a character is deleted.
(Contributed by Semyon Moroz in :gh:`77065`.)
graphlib
--------
-* Allow :meth:`graphlib.TopologicalSorter.prepare` to be called more than once
+* Allow :meth:`.TopologicalSorter.prepare` to be called more than once
as long as sorting has not started.
(Contributed by Daniel Pope in :gh:`130914`.)
heapq
-----
-* Add functions for working with max-heaps:
+* The :mod:`!heapq` module has improved support for working with max-heaps,
+ via the following new functions:
- * :func:`heapq.heapify_max`,
- * :func:`heapq.heappush_max`,
- * :func:`heapq.heappop_max`,
- * :func:`heapq.heapreplace_max`
- * :func:`heapq.heappushpop_max`
+ * :func:`~heapq.heapify_max`
+ * :func:`~heapq.heappush_max`
+ * :func:`~heapq.heappop_max`
+ * :func:`~heapq.heapreplace_max`
+ * :func:`~heapq.heappushpop_max`
hmac
the command-line interface (``python -m http.server``) through the following
options:
- * ``--tls-cert <path>``: Path to the TLS certificate file.
- * ``--tls-key <path>``: Optional path to the private key file.
- * ``--tls-password-file <path>``: Optional path to the password file for the private key.
+ * :option:`--tls-cert \<path\> <http.server --tls-cert>`:
+ Path to the TLS certificate file.
+ * :option:`--tls-key \<path\> <http.server --tls-key>`:
+ Optional path to the private key file.
+ * :option:`--tls-password-file \<path\> <http.server --tls-password-file>`:
+ Optional path to the password file for the private key.
(Contributed by Semyon Moroz in :gh:`85162`.)
imaplib
-------
-* Add :meth:`IMAP4.idle() <imaplib.IMAP4.idle>`, implementing the IMAP4
+* Add :meth:`.IMAP4.idle`, implementing the IMAP4
``IDLE`` command as defined in :rfc:`2177`.
(Contributed by Forest in :gh:`55454`.)
inspect
-------
-* :func:`inspect.signature` takes a new argument *annotation_format* to control
+* :func:`~inspect.signature` takes a new argument *annotation_format* to control
the :class:`annotationlib.Format` used for representing annotations.
(Contributed by Jelle Zijlstra in :gh:`101552`.)
-* :meth:`inspect.Signature.format` takes a new argument *unquote_annotations*.
- If true, string :term:`annotations <annotation>` are displayed without surrounding quotes.
+* :meth:`.Signature.format` takes a new argument *unquote_annotations*.
+ If true, string :term:`annotations <annotation>` are displayed without
+ surrounding quotes.
(Contributed by Jelle Zijlstra in :gh:`101552`.)
-* Add function :func:`inspect.ispackage` to determine whether an object is a
+* Add function :func:`~inspect.ispackage` to determine whether an object is a
:term:`package` or not.
(Contributed by Zhikang Yan in :gh:`125634`.)
:exc:`BlockingIOError` if the operation cannot immediately return bytes.
(Contributed by Giovanni Siragusa in :gh:`109523`.)
-* Add protocols :class:`io.Reader` and :class:`io.Writer` as simpler
+* Add the :class:`~io.Reader` and :class:`~io.Writer` protocols as simpler
alternatives to the pseudo-protocols :class:`typing.IO`,
:class:`typing.TextIO`, and :class:`typing.BinaryIO`.
(Contributed by Sebastian Rittau in :gh:`127648`.)
json
----
-* Add notes for JSON serialization errors that allow to identify the source
- of the error.
+* Add exception notes for JSON serialization errors that allow
+ identifying the source of the error.
(Contributed by Serhiy Storchaka in :gh:`122163`.)
-* Enable the :mod:`json` module to work as a script using the :option:`-m`
- switch: :program:`python -m json`.
+* Allow using the :mod:`json` module as a script using the :option:`-m` switch:
+ :program:`python -m json`.
+ This is now preferred to :program:`python -m json.tool`,
+ which is :term:`soft deprecated`.
See the :ref:`JSON command-line interface <json-commandline>` documentation.
(Contributed by Trey Hunner in :gh:`122873`.)
- .. _whatsnew314-color-json:
+.. _whatsnew314-color-json:
* By default, the output of the :ref:`JSON command-line interface
<json-commandline>` is highlighted in color.
<using-on-controlling-color>`.
(Contributed by Tomas Roun in :gh:`131952`.)
+
linecache
---------
-* :func:`linecache.getline` can retrieve source code for frozen modules.
+* :func:`~linecache.getline` can now retrieve source code for frozen modules.
(Contributed by Tian Gao in :gh:`131638`.)
logging.handlers
----------------
-* :class:`logging.handlers.QueueListener` now implements the context
- manager protocol, allowing it to be used in a :keyword:`with` statement.
+* :class:`~logging.handlers.QueueListener` objects now support the
+ :term:`context manager` protocol.
(Contributed by Charles Machalow in :gh:`132106`.)
* :meth:`QueueListener.start <logging.handlers.QueueListener.start>` now
mimetypes
---------
-* Document the command-line for :mod:`mimetypes`.
- It now exits with ``1`` on failure instead of ``0``
- and ``2`` on incorrect command-line parameters instead of ``1``.
- Also, errors are printed to stderr instead of stdout and their text is made
- tighter.
+* Add a public :ref:`command-line <mimetypes-cli>` for the module,
+ invoked via :program:`python -m mimetypes`.
(Contributed by Oleg Iarygin and Hugo van Kemenade in :gh:`93096`.)
-* Add MS and :rfc:`8081` MIME types for fonts:
+* Add several new MIME types based on RFCs and common usage:
+
+ .. rubric:: Microsoft and :rfc:`8081` MIME types for fonts
* Embedded OpenType: ``application/vnd.ms-fontobject``
* OpenType Layout (OTF) ``font/otf``
* WOFF 1.0 ``font/woff``
* WOFF 2.0 ``font/woff2``
- (Contributed by Sahil Prajapati and Hugo van Kemenade in :gh:`84852`.)
-
-* Add :rfc:`9559` MIME types for Matroska audiovisual data container
- structures, containing:
+ .. rubric:: :rfc:`9559` MIME types for Matroska audiovisual
+ data container structures
* audio with no video: ``audio/matroska`` (``.mka``)
* video: ``video/matroska`` (``.mkv``)
* stereoscopic video: ``video/matroska-3d`` (``.mk3d``)
- (Contributed by Hugo van Kemenade in :gh:`89416`.)
-
-* Add MIME types for images with RFCs:
+ .. rubric:: Images with RFCs
* :rfc:`1494`: CCITT Group 3 (``.g3``)
* :rfc:`3362`: Real-time Facsimile, T.38 (``.t38``)
* :rfc:`4047`: Flexible Image Transport System (``.fits``)
* :rfc:`7903`: Enhanced Metafile (``.emf``) and Windows Metafile (``.wmf``)
- (Contributed by Hugo van Kemenade in :gh:`85957`.)
-
-* More MIME type changes:
+ .. rubric:: Other MIME type additions and changes
* :rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi``
and for ``.wav`` to ``audio/vnd.wave``
* :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)
* :rfc:`6713`: Add gzip ``application/gzip`` (``.gz``)
* :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)
+ * :rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml``
+ and ``.yml``)
* Add 7z ``application/x-7z-compressed`` (``.7z``)
* Add Android Package ``application/vnd.android.package-archive`` (``.apk``)
when not strict
* `W3C <https://www.w3.org/TR/epub-33/#app-media-type>`__:
Add EPUB ``application/epub+zip`` (``.epub``)
- (Contributed by Hugo van Kemenade in :gh:`129965`.)
-
-* Add :rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml``
- and ``.yml``). (Contributed by Sasha "Nelie" Chernykh and Hugo van Kemenade
- in :gh:`132056`.)
+ (Contributed by Sahil Prajapati and Hugo van Kemenade in :gh:`84852`,
+ by Sasha "Nelie" Chernykh and Hugo van Kemenade in :gh:`132056`,
+ and by Hugo van Kemenade in :gh:`89416`, :gh:`85957`, and :gh:`129965`.)
multiprocessing
<multiprocessing-start-method-spawn>` remains the default start method.
If the threading incompatible *fork* method is required, you must explicitly
- request it via a context from :func:`multiprocessing.get_context` (preferred)
- or change the default via :func:`multiprocessing.set_start_method`.
+ request it via a context from :func:`~multiprocessing.get_context` (preferred)
+ or change the default via :func:`~multiprocessing.set_start_method`.
See :ref:`forkserver restrictions <multiprocessing-programming-forkserver>`
for information and differences with the *fork* method and how this change
(Contributed by Gregory P. Smith in :gh:`84559`.)
-* :mod:`multiprocessing`'s ``"forkserver"`` start method now authenticates
+* :mod:`multiprocessing`'s ``'forkserver'`` start method now authenticates
its control socket to avoid solely relying on filesystem permissions
to restrict what other processes could cause the forkserver to spawn workers
and run code.
(Contributed by Roy Hyunjin Han for :gh:`103134`.)
* Add support for shared :class:`set` objects via
- :meth:`SyncManager.set() <multiprocessing.managers.SyncManager.set>`.
- The :func:`set` in :func:`multiprocessing.Manager` method is now available.
+ :meth:`.SyncManager.set`.
+ The :func:`set` in :func:`~multiprocessing.Manager` method is now available.
(Contributed by Mingyu Park in :gh:`129949`.)
-* Add :func:`multiprocessing.Process.interrupt` which terminates the child
+* Add the :meth:`~multiprocessing.Process.interrupt`
+ to :class:`multiprocessing.Process` objects, which terminates the child
process by sending :py:const:`~signal.SIGINT`. This enables
:keyword:`finally` clauses to print a stack trace for the terminated
process. (Contributed by Artem Pulkin in :gh:`131913`.)
+
operator
--------
-* Two new functions :func:`operator.is_none` and :func:`operator.is_not_none`
- have been added, such that ``operator.is_none(obj)`` is equivalent
+* Add :func:`~operator.is_none` and :func:`~operator.is_not_none` as a pair
+ of functions, such that ``operator.is_none(obj)`` is equivalent
to ``obj is None`` and ``operator.is_not_none(obj)`` is equivalent
to ``obj is not None``.
(Contributed by Raymond Hettinger and Nico Mexis in :gh:`115808`.)
os
--
-* Add the :func:`os.reload_environ` function to update :data:`os.environ` and
+* Add the :func:`~os.reload_environ` function to update :data:`os.environ` and
:data:`os.environb` with changes to the environment made by
:func:`os.putenv`, by :func:`os.unsetenv`, or made outside Python in the
same process.
(Contributed by Victor Stinner in :gh:`120057`.)
* Add the :data:`~os.SCHED_DEADLINE` and :data:`~os.SCHED_NORMAL` constants
- to the :mod:`os` module.
+ to the :mod:`!os` module.
(Contributed by James Roy in :gh:`127688`.)
-* Add the :func:`os.readinto` function to read into a
+* Add the :func:`~os.readinto` function to read into a
:ref:`buffer object <bufferobjects>` from a file descriptor.
(Contributed by Cody Maloney in :gh:`129205`.)
os.path
-------
-* The *strict* parameter to :func:`os.path.realpath` accepts a new value,
- :data:`os.path.ALLOW_MISSING`.
+* The *strict* parameter to :func:`~os.path.realpath` accepts a new value,
+ :data:`~os.path.ALLOW_MISSING`.
If used, errors other than :exc:`FileNotFoundError` will be re-raised;
the resulting path can be missing but it will be free of symlinks.
(Contributed by Petr Viktorin for :cve:`2025-4517`.)
(Contributed by Barney Gale in :gh:`73991`.)
-* Add :attr:`pathlib.Path.info` attribute, which stores an object
- implementing the :class:`pathlib.types.PathInfo` protocol (also new). The
+* Add the :attr:`~pathlib.Path.info` attribute, which stores an object
+ implementing the new :class:`pathlib.types.PathInfo` protocol. The
object supports querying the file type and internally caching
:func:`~os.stat` results. Path objects generated by
:meth:`~pathlib.Path.iterdir` are initialized with file type information
pdb
---
-* Hardcoded breakpoints (:func:`breakpoint` and :func:`pdb.set_trace`) now
+* Hardcoded breakpoints (:func:`breakpoint` and :func:`~pdb.set_trace`) now
reuse the most recent :class:`~pdb.Pdb` instance that calls
:meth:`~pdb.Pdb.set_trace`, instead of creating a new one each time.
As a result, all the instance specific data like :pdbcmd:`display` and
* Set the default protocol version on the :mod:`pickle` module to 5.
For more details, see :ref:`pickle protocols <pickle-protocols>`.
-* Add notes for pickle serialization errors that allow to identify the source
- of the error.
+* Add exception notes for pickle serialization errors that allow
+ identifying the source of the error.
(Contributed by Serhiy Storchaka in :gh:`122213`.)
platform
--------
-* Add :func:`platform.invalidate_caches` to invalidate the cached results.
+* Add :func:`~platform.invalidate_caches`, a function to invalidate
+ cached results in the :mod:`!platform` module.
(Contributed by Bénédikt Tran in :gh:`122549`.)
unlike ``\Z``, which has subtly different behavior.
(Contributed by Serhiy Storchaka in :gh:`133306`.)
-* ``\B`` in :mod:`regular expression <re>` now matches the empty input string.
- Now it is always the opposite of ``\b``.
+* ``\B`` in :mod:`regular expression <re>` now matches the empty input string,
+ meaning that it is now always the opposite of ``\b``.
(Contributed by Serhiy Storchaka in :gh:`124130`.)
* Add many new constants.
(Contributed by Serhiy Storchaka in :gh:`132734`.)
+
ssl
---
-* Indicate through :data:`ssl.HAS_PHA` whether the :mod:`ssl` module supports
- TLSv1.3 post-handshake client authentication (PHA).
+* Indicate through the :data:`~ssl.HAS_PHA` Boolean whether the :mod:`!ssl`
+ module supports TLSv1.3 post-handshake client authentication (PHA).
(Contributed by Will Childs-Klein in :gh:`128036`.)
symtable
--------
-* Expose the following :class:`symtable.Symbol` methods:
+* Expose the following :class:`~symtable.Symbol` methods:
* :meth:`~symtable.Symbol.is_comp_cell`
* :meth:`~symtable.Symbol.is_comp_iter`
* The previously undocumented special function :func:`sys.getobjects`,
which only exists in specialized builds of Python, may now return objects
from other interpreters than the one it's called in.
+ (Contributed by Eric Snow in :gh:`125286`.)
* Add :func:`sys._is_immortal` for determining if an object is :term:`immortal`.
(Contributed by Peter Bierma in :gh:`128509`.)
-* On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
+* On FreeBSD, :data:`sys.platform` no longer contains the major version number.
It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
+ (Contributed by Michael Osipov in :gh:`129393`.)
* Raise :exc:`DeprecationWarning` for :func:`sys._clear_type_cache`. This
function was deprecated in Python 3.13 but it didn't raise a runtime warning.
+* Add :func:`sys.remote_exec` to implement the new external debugger interface.
+ See :ref:`PEP 768 <whatsnew314-pep768>` for details.
+ (Contributed by Pablo Galindo Salgado, Matt Wozniski, and Ivona Stojanovic
+ in :gh:`131591`.)
+
+* Add the :data:`sys._jit` namespace, containing utilities for introspecting
+ just-in-time compilation.
+ (Contributed by Brandt Bucher in :gh:`133231`.)
+
sys.monitoring
--------------
-* Two new events are added: :monitoring-event:`BRANCH_LEFT` and
- :monitoring-event:`BRANCH_RIGHT`. The ``BRANCH`` event is deprecated.
+* Add two new monitoring events, :monitoring-event:`BRANCH_LEFT` and
+ :monitoring-event:`BRANCH_RIGHT`.
+ These replace and deprecate the :monitoring-event:`!BRANCH` event.
+ (Contributed by Mark Shannon in :gh:`122548`.)
sysconfig
---------
-* Add ``ABIFLAGS`` key to :func:`sysconfig.get_config_vars` on Windows.
+* Add ``ABIFLAGS`` key to :func:`~sysconfig.get_config_vars` on Windows.
(Contributed by Xuehai Pan in :gh:`131799`.)
* :func:`~tarfile.data_filter` now normalizes symbolic link targets in order to
avoid path traversal attacks.
(Contributed by Petr Viktorin in :gh:`127987` and :cve:`2025-4138`.)
+
* :func:`~tarfile.TarFile.extractall` now skips fixing up directory attributes
when a directory was removed or replaced by another kind of file.
(Contributed by Petr Viktorin in :gh:`127987` and :cve:`2024-12718`.)
+
* :func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall`
now (re-)apply the extraction filter when substituting a link (hard or
symbolic) with a copy of another archive member, and when fixing up
directory attributes.
The former raises a new exception, :exc:`~tarfile.LinkFallbackError`.
(Contributed by Petr Viktorin for :cve:`2025-4330` and :cve:`2024-12718`.)
+
* :func:`~tarfile.TarFile.extract` and :func:`~tarfile.TarFile.extractall`
no longer extract rejected members when
:func:`~tarfile.TarFile.errorlevel` is zero.
-------
* Make :mod:`tkinter` widget methods :meth:`!after` and :meth:`!after_idle`
- accept arguments passed by keyword.
+ accept keyword arguments.
(Contributed by Zhikang Yan in :gh:`126899`.)
-* Add ability to specify name for :class:`!tkinter.OptionMenu` and
+* Add ability to specify a name for :class:`!tkinter.OptionMenu` and
:class:`!tkinter.ttk.OptionMenu`.
(Contributed by Zhikang Yan in :gh:`130482`.)
+
turtle
------
-* Add context managers for :func:`turtle.fill`, :func:`turtle.poly`
+* Add context managers for :func:`turtle.fill`, :func:`turtle.poly`,
and :func:`turtle.no_animation`.
(Contributed by Marie Roald and Yngve Mardal Moe in :gh:`126350`.)
.. _whatsnew314-typing-union:
-* :class:`types.UnionType` and :class:`typing.Union` are now aliases for each other,
- meaning that both old-style unions (created with ``Union[int, str]``) and new-style
- unions (``int | str``) now create instances of the same runtime type. This unifies
- the behavior between the two syntaxes, but leads to some differences in behavior that
+* The :class:`types.UnionType` and :class:`typing.Union` types are now
+ aliases for each other, meaning that both old-style unions
+ (created with ``Union[int, str]``) and new-style unions (``int | str``)
+ now create instances of the same runtime type. This unifies the behavior
+ between the two syntaxes, but leads to some differences in behavior that
may affect users who introspect types at runtime:
- - Both syntaxes for creating a union now produce the same string representation in
- ``repr()``. For example, ``repr(Union[int, str])``
- is now ``"int | str"`` instead of ``"typing.Union[int, str]"``.
- - Unions created using the old syntax are no longer cached. Previously, running
- ``Union[int, str]`` multiple times would return the same object
- (``Union[int, str] is Union[int, str]`` would be ``True``), but now it will
- return two different objects. Users should use ``==`` to compare unions for equality, not
- ``is``. New-style unions have never been cached this way.
- This change could increase memory usage for some programs that use a large number of
- unions created by subscripting ``typing.Union``. However, several factors offset this cost:
- unions used in annotations are no longer evaluated by default in Python 3.14
- because of :pep:`649`; an instance of :class:`types.UnionType` is
- itself much smaller than the object returned by ``Union[]`` was on prior Python
- versions; and removing the cache also saves some space. It is therefore
- unlikely that this change will cause a significant increase in memory usage for most
- users.
+ - Both syntaxes for creating a union now produce the same string
+ representation in :func:`repr`.
+ For example, ``repr(Union[int, str])`` is now ``"int | str"`` instead of
+ ``"typing.Union[int, str]"``.
+
+ - Unions created using the old syntax are no longer cached.
+ Previously, running ``Union[int, str]`` multiple times would return
+ the same object (``Union[int, str] is Union[int, str]`` would be ``True``),
+ but now it will return two different objects.
+ Use ``==`` to compare unions for equality, not ``is``.
+ New-style unions have never been cached this way.
+ This change could increase memory usage for some programs that use
+ a large number of unions created by subscripting ``typing.Union``.
+ However, several factors offset this cost:
+ unions used in annotations are no longer evaluated by default in Python
+ 3.14 because of :pep:`649`; an instance of :class:`types.UnionType` is
+ itself much smaller than the object returned by ``Union[]`` was on prior
+ Python versions; and removing the cache also saves some space.
+ It is therefore unlikely that this change will cause a significant increase
+ in memory usage for most users.
+
- Previously, old-style unions were implemented using the private class
- ``typing._UnionGenericAlias``. This class is no longer needed for the implementation,
- but it has been retained for backward compatibility, with removal scheduled for Python
- 3.17. Users should use documented introspection helpers like :func:`typing.get_origin`
- and :func:`typing.get_args` instead of relying on private implementation details.
- - It is now possible to use :class:`typing.Union` itself in :func:`isinstance` checks.
- For example, ``isinstance(int | str, typing.Union)`` will return ``True``; previously
- this raised :exc:`TypeError`.
- - The ``__args__`` attribute of :class:`typing.Union` objects is no longer writable.
- - It is no longer possible to set any attributes on :class:`typing.Union` objects.
+ ``typing._UnionGenericAlias``.
+ This class is no longer needed for the implementation,
+ but it has been retained for backward compatibility,
+ with removal scheduled for Python 3.17.
+ Users should use documented introspection helpers like
+ :func:`~typing.get_origin` and :func:`typing.get_args` instead of
+ relying on private implementation details.
+
+ - It is now possible to use :class:`typing.Union` itself in
+ :func:`isinstance` checks.
+ For example, ``isinstance(int | str, typing.Union)`` will return ``True``;
+ previously this raised :exc:`TypeError`.
+
+ - The :attr:`!__args__` attribute of :class:`typing.Union` objects is
+ no longer writable.
+
+ - It is no longer possible to set any attributes on :class:`~typing.Union`
+ objects.
This only ever worked for dunder attributes on previous versions, was never
documented to work, and was subtly broken in many cases.
(Contributed by Jelle Zijlstra in :gh:`105499`.)
-* :class:`typing.TypeAliasType` now supports star unpacking.
+* :class:`~typing.TypeAliasType` now supports star unpacking.
unicodedata
* The Unicode database has been updated to Unicode 16.0.0.
-.. _whatsnew314-color-unittest:
-
unittest
--------
+.. _whatsnew314-color-unittest:
+
* :mod:`unittest` output is now colored by default.
This can be controlled by :ref:`environment variables
<using-on-controlling-color>`.
* Improve ergonomics and standards compliance when parsing and emitting
``file:`` URLs.
- In :func:`urllib.request.url2pathname`:
+ In :func:`~urllib.request.url2pathname`:
- Accept a complete URL when the new *require_scheme* argument is set to
true.
- Raise :exc:`~urllib.error.URLError` if a URL authority isn't local,
except on Windows where we return a UNC path as before.
- In :func:`urllib.request.pathname2url`:
+ In :func:`~urllib.request.pathname2url`:
- Return a complete URL when the new *add_scheme* argument is set to true.
- Include an empty URL authority when a path begins with a slash. For
uuid
----
-* Add support for UUID versions 6, 7, and 8 via :func:`uuid.uuid6`,
- :func:`uuid.uuid7`, and :func:`uuid.uuid8` respectively, as specified
+* Add support for UUID versions 6, 7, and 8 via :func:`~uuid.uuid6`,
+ :func:`~uuid.uuid7`, and :func:`~uuid.uuid8` respectively, as specified
in :rfc:`9562`.
(Contributed by Bénédikt Tran in :gh:`89083`.)
-* :const:`uuid.NIL` and :const:`uuid.MAX` are now available to represent the
+* :const:`~uuid.NIL` and :const:`~uuid.MAX` are now available to represent the
Nil and Max UUID formats as defined by :rfc:`9562`.
(Contributed by Nick Pope in :gh:`128427`.)
-* Allow to generate multiple UUIDs at once via :option:`python -m uuid --count <uuid --count>`.
+* Allow generating multiple UUIDs simultaneously on the command-line via
+ :option:`python -m uuid --count <uuid --count>`.
(Contributed by Simon Legner in :gh:`131236`.)
zipfile
-------
-* Added :func:`ZipInfo._for_archive <zipfile.ZipInfo._for_archive>`
+* Added :meth:`ZipInfo._for_archive <zipfile.ZipInfo._for_archive>`, a method
to resolve suitable defaults for a :class:`~zipfile.ZipInfo` object
as used by :func:`ZipFile.writestr <zipfile.ZipFile.writestr>`.
(Contributed by Bénédikt Tran in :gh:`123424`.)
-* :meth:`zipfile.ZipFile.writestr` now respects ``SOURCE_DATE_EPOCH`` that
- distributions can set centrally and have build tools consume this in order
- to produce reproducible output.
+* :meth:`.ZipFile.writestr` now respects the :envvar:`SOURCE_DATE_EPOCH`
+ environment variable in order to better support reproducible builds.
(Contributed by Jiahao Li in :gh:`91279`.)
(Contributed by Adam Turner, Bénédikt Tran, Chris Markiewicz, Eli Schwartz,
Hugo van Kemenade, Jelle Zijlstra, and others in :gh:`118761`.)
-* The interpreter avoids some reference count modifications internally when
- it's safe to do so. This can lead to different values returned from
- :func:`sys.getrefcount` and :c:func:`Py_REFCNT` compared to previous versions
- of Python. See :ref:`below <whatsnew314-refcount>` for details.
+* The interpreter now avoids some reference count modifications internally
+ when it's safe to do so.
+ This can lead to different values being returned from :func:`sys.getrefcount`
+ and :c:func:`Py_REFCNT` compared to previous versions of Python.
+ See :ref:`below <whatsnew314-refcount>` for details.
asyncio
-------
-* Standard benchmark results have improved by 10-20%, following the
- implementation of a new per-thread double linked list
+* Standard benchmark results have improved by 10-20% following the
+ implementation of a new per-thread doubly linked list
for :class:`native tasks <asyncio.Task>`,
also reducing memory usage.
This enables external introspection tools such as
with annotations should continue to work, some undocumented details may behave
differently.
+* As part of making the :mod:`mimetypes` CLI public,
+ it now exits with ``1`` on failure instead of ``0``
+ and ``2`` on incorrect command-line parameters instead of ``1``.
+ Error messages are now printed to stderr.
+
+* The ``\B`` pattern in regular expression now matches the empty string
+ when given as the entire pattern, which may cause behavioural changes.
+
+* On FreeBSD, :data:`sys.platform` no longer contains the major version number.
+
Changes in the C API
--------------------