GH-109190: Copyedit 3.12 What's New: Deprecations (#109766)

This commit is contained in:
Adam Turner 2023-09-26 22:24:44 +01:00 committed by GitHub
parent 4390c13148
commit 87ddfa74e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -580,19 +580,10 @@ asyncio
:class:`asyncio.ThreadedChildWatcher`. :class:`asyncio.ThreadedChildWatcher`.
(Contributed by Kumar Aditya in :gh:`98024`.) (Contributed by Kumar Aditya in :gh:`98024`.)
* The child watcher classes :class:`asyncio.MultiLoopChildWatcher`, * The event loop now uses the best available child watcher for each platform
:class:`asyncio.FastChildWatcher`, :class:`asyncio.AbstractChildWatcher` (:class:`asyncio.PidfdChildWatcher` if supported and
and :class:`asyncio.SafeChildWatcher` are deprecated and :class:`asyncio.ThreadedChildWatcher` otherwise), so manually
will be removed in Python 3.14. It is recommended to not manually configuring a child watcher is not recommended.
configure a child watcher as the event loop now uses the best available
child watcher for each platform (:class:`asyncio.PidfdChildWatcher`
if supported and :class:`asyncio.ThreadedChildWatcher` otherwise).
(Contributed by Kumar Aditya in :gh:`94597`.)
* :func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`,
:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` and
:meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated
and will be removed in Python 3.14.
(Contributed by Kumar Aditya in :gh:`94597`.) (Contributed by Kumar Aditya in :gh:`94597`.)
* Add *loop_factory* parameter to :func:`asyncio.run` to allow specifying * Add *loop_factory* parameter to :func:`asyncio.run` to allow specifying
@ -1046,15 +1037,52 @@ Demos and Tools
Deprecated Deprecated
========== ==========
* :mod:`asyncio`: The :meth:`~asyncio.get_event_loop` method of the * :mod:`argparse`: The *type*, *choices*, and *metavar* parameters
default event loop policy now emits a :exc:`DeprecationWarning` if there of :class:`!argparse.BooleanOptionalAction` are deprecated
is no current event loop set and it decides to create one. and will be removed in 3.14.
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.) (Contributed by Nikita Sobolev in :gh:`92248`.)
* :mod:`ast`: The following :mod:`ast` features have been deprecated in documentation since
Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at runtime
when they are accessed or used, and will be removed in Python 3.14:
* :class:`!ast.Num`
* :class:`!ast.Str`
* :class:`!ast.Bytes`
* :class:`!ast.NameConstant`
* :class:`!ast.Ellipsis`
Use :class:`ast.Constant` instead.
(Contributed by Serhiy Storchaka in :gh:`90953`.)
* :mod:`asyncio`:
* The child watcher classes :class:`asyncio.MultiLoopChildWatcher`,
:class:`asyncio.FastChildWatcher`, :class:`asyncio.AbstractChildWatcher`
and :class:`asyncio.SafeChildWatcher` are deprecated and
will be removed in Python 3.14.
(Contributed by Kumar Aditya in :gh:`94597`.)
* :func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`,
:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` and
:meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated
and will be removed in Python 3.14.
(Contributed by Kumar Aditya in :gh:`94597`.)
* The :meth:`~asyncio.get_event_loop` method of the
default event loop policy now emits a :exc:`DeprecationWarning` if there
is no current event loop set and it decides to create one.
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
* :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are deprecated and * :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are deprecated and
replaced by :data:`calendar.JANUARY` and :data:`calendar.FEBRUARY`. replaced by :data:`calendar.JANUARY` and :data:`calendar.FEBRUARY`.
(Contributed by Prince Roshan in :gh:`103636`.) (Contributed by Prince Roshan in :gh:`103636`.)
* :mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`.
Prefer :class:`Sequence` or :class:`collections.abc.Buffer`.
For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`.
(Contributed by Shantanu Jain in :gh:`91896`.)
* :mod:`datetime`: :class:`datetime.datetime`'s :meth:`~datetime.datetime.utcnow` and * :mod:`datetime`: :class:`datetime.datetime`'s :meth:`~datetime.datetime.utcnow` and
:meth:`~datetime.datetime.utcfromtimestamp` are deprecated and will be :meth:`~datetime.datetime.utcfromtimestamp` are deprecated and will be
removed in a future version. Instead, use timezone-aware objects to represent removed in a future version. Instead, use timezone-aware objects to represent
@ -1063,12 +1091,55 @@ Deprecated
:const:`datetime.UTC`. :const:`datetime.UTC`.
(Contributed by Paul Ganssle in :gh:`103857`.) (Contributed by Paul Ganssle in :gh:`103857`.)
* :mod:`email`: Deprecate the *isdst* parameter in :func:`email.utils.localtime`.
(Contributed by Alan Williams in :gh:`72346`.)
* :mod:`importlib.abc`: Deprecated the following classes, scheduled for removal in
Python 3.14:
* :class:`!importlib.abc.ResourceReader`
* :class:`!importlib.abc.Traversable`
* :class:`!importlib.abc.TraversableResources`
Use :mod:`importlib.resources.abc` classes instead:
* :class:`importlib.resources.abc.Traversable`
* :class:`importlib.resources.abc.TraversableResources`
(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)
* :mod:`itertools`: Deprecate the support for copy, deepcopy, and pickle operations,
which is undocumented, inefficient, historically buggy, and inconsistent.
This will be removed in 3.14 for a significant reduction in code
volume and maintenance burden.
(Contributed by Raymond Hettinger in :gh:`101588`.)
* :mod:`os`: The ``st_ctime`` fields return by :func:`os.stat` and :func:`os.lstat` on * :mod:`os`: The ``st_ctime`` fields return by :func:`os.stat` and :func:`os.lstat` on
Windows are deprecated. In a future release, they will contain the last Windows are deprecated. In a future release, they will contain the last
metadata change time, consistent with other platforms. For now, they still metadata change time, consistent with other platforms. For now, they still
contain the creation time, which is also available in the new ``st_birthtime`` contain the creation time, which is also available in the new ``st_birthtime``
field. (Contributed by Steve Dower in :gh:`99726`.) field. (Contributed by Steve Dower in :gh:`99726`.)
* :mod:`multiprocessing`: In Python 3.14, the default :mod:`multiprocessing`
start method will change to a safer one on Linux, BSDs,
and other non-macOS POSIX platforms where ``'fork'`` is currently
the default (:gh:`84559`). Adding a runtime warning about this was deemed too
disruptive as the majority of code is not expected to care. Use the
:func:`~multiprocessing.get_context` or
:func:`~multiprocessing.set_start_method` APIs to explicitly specify when
your code *requires* ``'fork'``. See :ref:`contexts and start methods
<multiprocessing-start-methods>`.
* :mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader`
are deprecated and will be removed in Python 3.14;
use :func:`importlib.util.find_spec` instead.
(Contributed by Nikita Sobolev in :gh:`97850`.)
* :mod:`pty`: The module has two undocumented ``master_open()`` and ``slave_open()``
functions that have been deprecated since Python 2 but only gained a
proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14.
(Contributed by Soumendra Ganguly and Gregory P. Smith in :gh:`85984`.)
* :mod:`os`: On POSIX platforms, :func:`os.fork` can now raise a * :mod:`os`: On POSIX platforms, :func:`os.fork` can now raise a
:exc:`DeprecationWarning` when it can detect being called from a :exc:`DeprecationWarning` when it can detect being called from a
multithreaded process. There has always been a fundamental incompatibility multithreaded process. There has always been a fundamental incompatibility
@ -1083,22 +1154,23 @@ Deprecated
:mod:`concurrent.futures` the fix is to use a different :mod:`concurrent.futures` the fix is to use a different
:mod:`multiprocessing` start method such as ``"spawn"`` or ``"forkserver"``. :mod:`multiprocessing` start method such as ``"spawn"`` or ``"forkserver"``.
* :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is deprecated as will be removed * :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is deprecated and will be removed
in Python 3.14. Use *onexc* instead. (Contributed by Irit Katriel in :gh:`102828`.) in Python 3.14. Use *onexc* instead. (Contributed by Irit Katriel in :gh:`102828`.)
* :mod:`sqlite3`: * :mod:`sqlite3`:
* :ref:`default adapters and converters
<sqlite3-default-converters>` are now deprecated.
Instead, use the :ref:`sqlite3-adapter-converter-recipes`
and tailor them to your needs.
(Contributed by Erlend E. Aasland in :gh:`90016`.)
* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted * :ref:`default adapters and converters
when :ref:`named placeholders <sqlite3-placeholders>` are used together with <sqlite3-default-converters>` are now deprecated.
parameters supplied as a :term:`sequence` instead of as a :class:`dict`. Instead, use the :ref:`sqlite3-adapter-converter-recipes`
Starting from Python 3.14, using named placeholders with parameters supplied and tailor them to your needs.
as a sequence will raise a :exc:`~sqlite3.ProgrammingError`. (Contributed by Erlend E. Aasland in :gh:`90016`.)
(Contributed by Erlend E. Aasland in :gh:`101698`.)
* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted
when :ref:`named placeholders <sqlite3-placeholders>` are used together with
parameters supplied as a :term:`sequence` instead of as a :class:`dict`.
Starting from Python 3.14, using named placeholders with parameters supplied
as a sequence will raise a :exc:`~sqlite3.ProgrammingError`.
(Contributed by Erlend E. Aasland in :gh:`101698`.)
* :mod:`sys`: The :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys.last_traceback` * :mod:`sys`: The :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys.last_traceback`
fields are deprecated. Use :data:`sys.last_exc` instead. fields are deprecated. Use :data:`sys.last_exc` instead.
@ -1108,16 +1180,24 @@ Deprecated
Python 3.14, when ``'data'`` filter will become the default. Python 3.14, when ``'data'`` filter will become the default.
See :ref:`tarfile-extraction-filter` for details. See :ref:`tarfile-extraction-filter` for details.
* :mod:`typing`: :class:`typing.Hashable` and :class:`typing.Sized` aliases for :class:`collections.abc.Hashable` * :mod:`typing`:
and :class:`collections.abc.Sized`. (:gh:`94309`.)
* :class:`typing.Hashable` and :class:`typing.Sized` aliases for :class:`collections.abc.Hashable`
and :class:`collections.abc.Sized`. (:gh:`94309`.)
* :class:`typing.ByteString`, deprecated since Python 3.9, now causes a
:exc:`DeprecationWarning` to be emitted when it is used.
(Contributed by Alex Waygood in :gh:`91896`.)
* :mod:`xml.etree.ElementTree`: The module now emits :exc:`DeprecationWarning` * :mod:`xml.etree.ElementTree`: The module now emits :exc:`DeprecationWarning`
when testing the truth value of an :class:`xml.etree.ElementTree.Element`. when testing the truth value of an :class:`xml.etree.ElementTree.Element`.
Before, the Python implementation emitted :exc:`FutureWarning`, and the C Before, the Python implementation emitted :exc:`FutureWarning`, and the C
implementation emitted nothing. implementation emitted nothing.
(Contributed by Jacob Walls in :gh:`83122`.)
* The 3-arg signatures (type, value, traceback) of :meth:`~coroutine.throw`, * The 3-arg signatures (type, value, traceback) of :meth:`coroutine throw()
:meth:`~generator.throw` and :meth:`~agen.athrow` are deprecated and <coroutine.throw>`, :meth:`generator throw() <generator.throw>` and
:meth:`async generator throw() <agen.athrow>` are deprecated and
may be removed in a future version of Python. Use the single-arg versions may be removed in a future version of Python. Use the single-arg versions
of these functions instead. (Contributed by Ofey Chan in :gh:`89874`.) of these functions instead. (Contributed by Ofey Chan in :gh:`89874`.)
@ -1126,12 +1206,21 @@ Deprecated
:exc:`ImportWarning`). :exc:`ImportWarning`).
(Contributed by Brett Cannon in :gh:`65961`.) (Contributed by Brett Cannon in :gh:`65961`.)
* Setting ``__package__`` or ``__cached__`` on a module is deprecated,
and will cease to be set or taken into consideration by the import system in Python 3.14.
(Contributed by Brett Cannon in :gh:`65961`.)
* The bitwise inversion operator (``~``) on bool is deprecated. It will throw an * The bitwise inversion operator (``~``) on bool is deprecated. It will throw an
error in Python 3.14. Use ``not`` for logical negation of bools instead. error in Python 3.14. Use ``not`` for logical negation of bools instead.
In the rare case that you really need the bitwise inversion of the underlying In the rare case that you really need the bitwise inversion of the underlying
``int``, convert to int explicitly with ``~int(x)``. (Contributed by Tim Hoffmann ``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
in :gh:`103487`.) in :gh:`103487`.)
* Accessing ``co_lnotab`` on code objects was deprecated in Python 3.10 via :pep:`626`,
but it only got a proper :exc:`DeprecationWarning` in 3.12,
therefore it will be removed in 3.14.
(Contributed by Nikita Sobolev in :gh:`101866`.)
Pending Removal in Python 3.13 Pending Removal in Python 3.13
------------------------------ ------------------------------
@ -1180,14 +1269,13 @@ APIs:
Pending Removal in Python 3.14 Pending Removal in Python 3.14
------------------------------ ------------------------------
* :mod:`argparse`: The *type*, *choices*, and *metavar* parameters The following APIs have been deprecated
of :class:`!argparse.BooleanOptionalAction` are deprecated and will be removed in Python 3.14.
and will be removed in 3.14.
(Contributed by Nikita Sobolev in :gh:`92248`.)
* :mod:`ast`: The following :mod:`ast` features have been deprecated in documentation since * :mod:`argparse`: The *type*, *choices*, and *metavar* parameters
Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at runtime of :class:`!argparse.BooleanOptionalAction`
when they are accessed or used, and will be removed in Python 3.14:
* :mod:`ast`:
* :class:`!ast.Num` * :class:`!ast.Num`
* :class:`!ast.Str` * :class:`!ast.Str`
@ -1195,75 +1283,48 @@ Pending Removal in Python 3.14
* :class:`!ast.NameConstant` * :class:`!ast.NameConstant`
* :class:`!ast.Ellipsis` * :class:`!ast.Ellipsis`
Use :class:`ast.Constant` instead. * :mod:`asyncio`:
(Contributed by Serhiy Storchaka in :gh:`90953`.)
* :mod:`asyncio`: the *msg* parameter of both * :class:`!asyncio.MultiLoopChildWatcher`
:meth:`asyncio.Future.cancel` and * :class:`!asyncio.FastChildWatcher`
:meth:`asyncio.Task.cancel` (:gh:`90985`) * :class:`!asyncio.AbstractChildWatcher`
* :class:`!asyncio.SafeChildWatcher`
* :func:`!asyncio.set_child_watcher`
* :func:`!asyncio.get_child_watcher`,
* :meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher`
* :meth:`!asyncio.AbstractEventLoopPolicy.get_child_watcher`
* :mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`. * :mod:`collections.abc`: :class:`!collections.abc.ByteString`.
Prefer :class:`Sequence` or :class:`collections.abc.Buffer`.
For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`.
(Contributed by Shantanu Jain in :gh:`91896`.)
* :mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils.localtime`. * :mod:`email`: the *isdst* parameter in :func:`email.utils.localtime`.
(Contributed by Alan Williams in :gh:`72346`.)
* :mod:`importlib.abc`: Deprecated the following classes, scheduled for removal in * :mod:`importlib.abc`:
Python 3.14:
* :class:`!importlib.abc.ResourceReader` * :class:`!importlib.abc.ResourceReader`
* :class:`!importlib.abc.Traversable` * :class:`!importlib.abc.Traversable`
* :class:`!importlib.abc.TraversableResources` * :class:`!importlib.abc.TraversableResources`
Use :mod:`importlib.resources.abc` classes instead: * :mod:`itertools`: Support for copy, deepcopy, and pickle operations.
* :class:`importlib.resources.abc.Traversable` * :mod:`pkgutil`:
* :class:`importlib.resources.abc.TraversableResources`
(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.) * :func:`!pkgutil.find_loader`
* :func:`!pkgutil.get_loader`.
* :mod:`itertools`: The module had undocumented, inefficient, historically buggy, * :mod:`pty`:
and inconsistent support for copy, deepcopy, and pickle operations.
This will be removed in 3.14 for a significant reduction in code
volume and maintenance burden.
(Contributed by Raymond Hettinger in :gh:`101588`.)
* :mod:`multiprocessing`: The default :mod:`multiprocessing` start method will change to a safer one on * :func:`!pty.master_open`
Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is currently * :func:`!pty.slave_open`
the default (:gh:`84559`). Adding a runtime warning about this was deemed too
disruptive as the majority of code is not expected to care. Use the
:func:`~multiprocessing.get_context` or
:func:`~multiprocessing.set_start_method` APIs to explicitly specify when
your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`.
* :mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader` * :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree`
now raise :exc:`DeprecationWarning`;
use :func:`importlib.util.find_spec` instead.
(Contributed by Nikita Sobolev in :gh:`97850`.)
* :mod:`pty`: The module has two undocumented ``master_open()`` and ``slave_open()`` * :mod:`typing`: :class:`!typing.ByteString`
functions that have been deprecated since Python 2 but only gained a
proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14.
* :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is deprecated in 3.12, * :mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`xml.etree.ElementTree.Element`.
and will be removed in 3.14.
* :mod:`typing`: :class:`typing.ByteString`, deprecated since Python 3.9, now causes a * The ``__package__`` and ``__cached__`` attributes on module objects.
:exc:`DeprecationWarning` to be emitted when it is used.
* :mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`xml.etree.ElementTree.Element` * The ``co_lnotab`` attribute of code objects.
is deprecated and will raise an exception in Python 3.14.
* ``__package__`` and ``__cached__`` will cease to be set or taken
into consideration by the import system (:gh:`97879`).
* Accessing ``co_lnotab`` was deprecated in :pep:`626` since 3.10
and was planned to be removed in 3.12
but it only got a proper :exc:`DeprecationWarning` in 3.12.
May be removed in 3.14.
(Contributed by Nikita Sobolev in :gh:`101866`.)
Pending Removal in Future Versions Pending Removal in Future Versions
---------------------------------- ----------------------------------