Skip to content

Commit 1d6ef7e

Browse files
[3.12] GH-109190: Copyedit 3.12 What's New: Deprecations (GH-109766) (#109925)
* GH-109190: Copyedit 3.12 What's New: Deprecations (GH-109766) (cherry picked from commit 87ddfa7) Co-authored-by: Adam Turner <[email protected]> * GH-109190: Copyedit 3.12 What's New: Deprecations (``os`` fix) (#109927) Merge the two ``os`` entries (cherry picked from commit 0e28d0f) --------- Co-authored-by: Adam Turner <[email protected]>
1 parent 648198c commit 1d6ef7e

File tree

1 file changed

+170
-107
lines changed

1 file changed

+170
-107
lines changed

Doc/whatsnew/3.12.rst

+170-107
Original file line numberDiff line numberDiff line change
@@ -580,19 +580,10 @@ asyncio
580580
:class:`asyncio.ThreadedChildWatcher`.
581581
(Contributed by Kumar Aditya in :gh:`98024`.)
582582

583-
* The child watcher classes :class:`asyncio.MultiLoopChildWatcher`,
584-
:class:`asyncio.FastChildWatcher`, :class:`asyncio.AbstractChildWatcher`
585-
and :class:`asyncio.SafeChildWatcher` are deprecated and
586-
will be removed in Python 3.14. It is recommended to not manually
587-
configure a child watcher as the event loop now uses the best available
588-
child watcher for each platform (:class:`asyncio.PidfdChildWatcher`
589-
if supported and :class:`asyncio.ThreadedChildWatcher` otherwise).
590-
(Contributed by Kumar Aditya in :gh:`94597`.)
591-
592-
* :func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`,
593-
:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` and
594-
:meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated
595-
and will be removed in Python 3.14.
583+
* The event loop now uses the best available child watcher for each platform
584+
(:class:`asyncio.PidfdChildWatcher` if supported and
585+
:class:`asyncio.ThreadedChildWatcher` otherwise), so manually
586+
configuring a child watcher is not recommended.
596587
(Contributed by Kumar Aditya in :gh:`94597`.)
597588

598589
* Add *loop_factory* parameter to :func:`asyncio.run` to allow specifying
@@ -1046,15 +1037,52 @@ Demos and Tools
10461037
Deprecated
10471038
==========
10481039

1049-
* :mod:`asyncio`: The :meth:`~asyncio.get_event_loop` method of the
1050-
default event loop policy now emits a :exc:`DeprecationWarning` if there
1051-
is no current event loop set and it decides to create one.
1052-
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
1040+
* :mod:`argparse`: The *type*, *choices*, and *metavar* parameters
1041+
of :class:`!argparse.BooleanOptionalAction` are deprecated
1042+
and will be removed in 3.14.
1043+
(Contributed by Nikita Sobolev in :gh:`92248`.)
1044+
1045+
* :mod:`ast`: The following :mod:`ast` features have been deprecated in documentation since
1046+
Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at runtime
1047+
when they are accessed or used, and will be removed in Python 3.14:
1048+
1049+
* :class:`!ast.Num`
1050+
* :class:`!ast.Str`
1051+
* :class:`!ast.Bytes`
1052+
* :class:`!ast.NameConstant`
1053+
* :class:`!ast.Ellipsis`
1054+
1055+
Use :class:`ast.Constant` instead.
1056+
(Contributed by Serhiy Storchaka in :gh:`90953`.)
1057+
1058+
* :mod:`asyncio`:
1059+
1060+
* The child watcher classes :class:`asyncio.MultiLoopChildWatcher`,
1061+
:class:`asyncio.FastChildWatcher`, :class:`asyncio.AbstractChildWatcher`
1062+
and :class:`asyncio.SafeChildWatcher` are deprecated and
1063+
will be removed in Python 3.14.
1064+
(Contributed by Kumar Aditya in :gh:`94597`.)
1065+
1066+
* :func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`,
1067+
:meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` and
1068+
:meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated
1069+
and will be removed in Python 3.14.
1070+
(Contributed by Kumar Aditya in :gh:`94597`.)
1071+
1072+
* The :meth:`~asyncio.get_event_loop` method of the
1073+
default event loop policy now emits a :exc:`DeprecationWarning` if there
1074+
is no current event loop set and it decides to create one.
1075+
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
10531076

10541077
* :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are deprecated and
10551078
replaced by :data:`calendar.JANUARY` and :data:`calendar.FEBRUARY`.
10561079
(Contributed by Prince Roshan in :gh:`103636`.)
10571080

1081+
* :mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`.
1082+
Prefer :class:`Sequence` or :class:`collections.abc.Buffer`.
1083+
For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`.
1084+
(Contributed by Shantanu Jain in :gh:`91896`.)
1085+
10581086
* :mod:`datetime`: :class:`datetime.datetime`'s :meth:`~datetime.datetime.utcnow` and
10591087
:meth:`~datetime.datetime.utcfromtimestamp` are deprecated and will be
10601088
removed in a future version. Instead, use timezone-aware objects to represent
@@ -1063,42 +1091,88 @@ Deprecated
10631091
:const:`datetime.UTC`.
10641092
(Contributed by Paul Ganssle in :gh:`103857`.)
10651093

1066-
* :mod:`os`: The ``st_ctime`` fields return by :func:`os.stat` and :func:`os.lstat` on
1067-
Windows are deprecated. In a future release, they will contain the last
1068-
metadata change time, consistent with other platforms. For now, they still
1069-
contain the creation time, which is also available in the new ``st_birthtime``
1070-
field. (Contributed by Steve Dower in :gh:`99726`.)
1071-
1072-
* :mod:`os`: On POSIX platforms, :func:`os.fork` can now raise a
1073-
:exc:`DeprecationWarning` when it can detect being called from a
1074-
multithreaded process. There has always been a fundamental incompatibility
1075-
with the POSIX platform when doing so. Even if such code *appeared* to work.
1076-
We added the warning to to raise awareness as issues encounted by code doing
1077-
this are becoming more frequent. See the :func:`os.fork` documentation for
1078-
more details along with `this discussion on fork being incompatible with threads
1079-
<https://discuss.python.org/t/33555>`_ for *why* we're now surfacing this
1080-
longstanding platform compatibility problem to developers.
1094+
* :mod:`email`: Deprecate the *isdst* parameter in :func:`email.utils.localtime`.
1095+
(Contributed by Alan Williams in :gh:`72346`.)
1096+
1097+
* :mod:`importlib.abc`: Deprecated the following classes, scheduled for removal in
1098+
Python 3.14:
1099+
1100+
* :class:`!importlib.abc.ResourceReader`
1101+
* :class:`!importlib.abc.Traversable`
1102+
* :class:`!importlib.abc.TraversableResources`
1103+
1104+
Use :mod:`importlib.resources.abc` classes instead:
1105+
1106+
* :class:`importlib.resources.abc.Traversable`
1107+
* :class:`importlib.resources.abc.TraversableResources`
1108+
1109+
(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)
1110+
1111+
* :mod:`itertools`: Deprecate the support for copy, deepcopy, and pickle operations,
1112+
which is undocumented, inefficient, historically buggy, and inconsistent.
1113+
This will be removed in 3.14 for a significant reduction in code
1114+
volume and maintenance burden.
1115+
(Contributed by Raymond Hettinger in :gh:`101588`.)
1116+
1117+
* :mod:`multiprocessing`: In Python 3.14, the default :mod:`multiprocessing`
1118+
start method will change to a safer one on Linux, BSDs,
1119+
and other non-macOS POSIX platforms where ``'fork'`` is currently
1120+
the default (:gh:`84559`). Adding a runtime warning about this was deemed too
1121+
disruptive as the majority of code is not expected to care. Use the
1122+
:func:`~multiprocessing.get_context` or
1123+
:func:`~multiprocessing.set_start_method` APIs to explicitly specify when
1124+
your code *requires* ``'fork'``. See :ref:`contexts and start methods
1125+
<multiprocessing-start-methods>`.
1126+
1127+
* :mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader`
1128+
are deprecated and will be removed in Python 3.14;
1129+
use :func:`importlib.util.find_spec` instead.
1130+
(Contributed by Nikita Sobolev in :gh:`97850`.)
1131+
1132+
* :mod:`pty`: The module has two undocumented ``master_open()`` and ``slave_open()``
1133+
functions that have been deprecated since Python 2 but only gained a
1134+
proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14.
1135+
(Contributed by Soumendra Ganguly and Gregory P. Smith in :gh:`85984`.)
1136+
1137+
* :mod:`os`:
1138+
1139+
* The ``st_ctime`` fields return by :func:`os.stat` and :func:`os.lstat` on
1140+
Windows are deprecated. In a future release, they will contain the last
1141+
metadata change time, consistent with other platforms. For now, they still
1142+
contain the creation time, which is also available in the new ``st_birthtime``
1143+
field. (Contributed by Steve Dower in :gh:`99726`.)
1144+
1145+
* On POSIX platforms, :func:`os.fork` can now raise a
1146+
:exc:`DeprecationWarning` when it can detect being called from a
1147+
multithreaded process. There has always been a fundamental incompatibility
1148+
with the POSIX platform when doing so. Even if such code *appeared* to work.
1149+
We added the warning to to raise awareness as issues encounted by code doing
1150+
this are becoming more frequent. See the :func:`os.fork` documentation for
1151+
more details along with `this discussion on fork being incompatible with threads
1152+
<https://discuss.python.org/t/33555>`_ for *why* we're now surfacing this
1153+
longstanding platform compatibility problem to developers.
10811154

10821155
When this warning appears due to usage of :mod:`multiprocessing` or
10831156
:mod:`concurrent.futures` the fix is to use a different
10841157
:mod:`multiprocessing` start method such as ``"spawn"`` or ``"forkserver"``.
10851158

1086-
* :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is deprecated as will be removed
1159+
* :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is deprecated and will be removed
10871160
in Python 3.14. Use *onexc* instead. (Contributed by Irit Katriel in :gh:`102828`.)
10881161

10891162
* :mod:`sqlite3`:
1090-
* :ref:`default adapters and converters
1091-
<sqlite3-default-converters>` are now deprecated.
1092-
Instead, use the :ref:`sqlite3-adapter-converter-recipes`
1093-
and tailor them to your needs.
1094-
(Contributed by Erlend E. Aasland in :gh:`90016`.)
1095-
1096-
* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted
1097-
when :ref:`named placeholders <sqlite3-placeholders>` are used together with
1098-
parameters supplied as a :term:`sequence` instead of as a :class:`dict`.
1099-
Starting from Python 3.14, using named placeholders with parameters supplied
1100-
as a sequence will raise a :exc:`~sqlite3.ProgrammingError`.
1101-
(Contributed by Erlend E. Aasland in :gh:`101698`.)
1163+
1164+
* :ref:`default adapters and converters
1165+
<sqlite3-default-converters>` are now deprecated.
1166+
Instead, use the :ref:`sqlite3-adapter-converter-recipes`
1167+
and tailor them to your needs.
1168+
(Contributed by Erlend E. Aasland in :gh:`90016`.)
1169+
1170+
* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted
1171+
when :ref:`named placeholders <sqlite3-placeholders>` are used together with
1172+
parameters supplied as a :term:`sequence` instead of as a :class:`dict`.
1173+
Starting from Python 3.14, using named placeholders with parameters supplied
1174+
as a sequence will raise a :exc:`~sqlite3.ProgrammingError`.
1175+
(Contributed by Erlend E. Aasland in :gh:`101698`.)
11021176

11031177
* :mod:`sys`: The :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys.last_traceback`
11041178
fields are deprecated. Use :data:`sys.last_exc` instead.
@@ -1108,16 +1182,24 @@ Deprecated
11081182
Python 3.14, when ``'data'`` filter will become the default.
11091183
See :ref:`tarfile-extraction-filter` for details.
11101184

1111-
* :mod:`typing`: :class:`typing.Hashable` and :class:`typing.Sized` aliases for :class:`collections.abc.Hashable`
1112-
and :class:`collections.abc.Sized`. (:gh:`94309`.)
1185+
* :mod:`typing`:
1186+
1187+
* :class:`typing.Hashable` and :class:`typing.Sized` aliases for :class:`collections.abc.Hashable`
1188+
and :class:`collections.abc.Sized`. (:gh:`94309`.)
1189+
1190+
* :class:`typing.ByteString`, deprecated since Python 3.9, now causes a
1191+
:exc:`DeprecationWarning` to be emitted when it is used.
1192+
(Contributed by Alex Waygood in :gh:`91896`.)
11131193

11141194
* :mod:`xml.etree.ElementTree`: The module now emits :exc:`DeprecationWarning`
11151195
when testing the truth value of an :class:`xml.etree.ElementTree.Element`.
11161196
Before, the Python implementation emitted :exc:`FutureWarning`, and the C
11171197
implementation emitted nothing.
1198+
(Contributed by Jacob Walls in :gh:`83122`.)
11181199

1119-
* The 3-arg signatures (type, value, traceback) of :meth:`~coroutine.throw`,
1120-
:meth:`~generator.throw` and :meth:`~agen.athrow` are deprecated and
1200+
* The 3-arg signatures (type, value, traceback) of :meth:`coroutine throw()
1201+
<coroutine.throw>`, :meth:`generator throw() <generator.throw>` and
1202+
:meth:`async generator throw() <agen.athrow>` are deprecated and
11211203
may be removed in a future version of Python. Use the single-arg versions
11221204
of these functions instead. (Contributed by Ofey Chan in :gh:`89874`.)
11231205

@@ -1126,12 +1208,21 @@ Deprecated
11261208
:exc:`ImportWarning`).
11271209
(Contributed by Brett Cannon in :gh:`65961`.)
11281210

1211+
* Setting ``__package__`` or ``__cached__`` on a module is deprecated,
1212+
and will cease to be set or taken into consideration by the import system in Python 3.14.
1213+
(Contributed by Brett Cannon in :gh:`65961`.)
1214+
11291215
* The bitwise inversion operator (``~``) on bool is deprecated. It will throw an
11301216
error in Python 3.14. Use ``not`` for logical negation of bools instead.
11311217
In the rare case that you really need the bitwise inversion of the underlying
1132-
``int``, convert to int explicitly with ``~int(x)``. (Contributed by Tim Hoffmann
1218+
``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
11331219
in :gh:`103487`.)
11341220

1221+
* Accessing ``co_lnotab`` on code objects was deprecated in Python 3.10 via :pep:`626`,
1222+
but it only got a proper :exc:`DeprecationWarning` in 3.12,
1223+
therefore it will be removed in 3.14.
1224+
(Contributed by Nikita Sobolev in :gh:`101866`.)
1225+
11351226
Pending Removal in Python 3.13
11361227
------------------------------
11371228

@@ -1179,90 +1270,62 @@ APIs:
11791270
Pending Removal in Python 3.14
11801271
------------------------------
11811272

1273+
The following APIs have been deprecated
1274+
and will be removed in Python 3.14.
1275+
11821276
* :mod:`argparse`: The *type*, *choices*, and *metavar* parameters
1183-
of :class:`!argparse.BooleanOptionalAction` are deprecated
1184-
and will be removed in 3.14.
1185-
(Contributed by Nikita Sobolev in :gh:`92248`.)
1277+
of :class:`!argparse.BooleanOptionalAction`
11861278

1187-
* :mod:`ast`: The following :mod:`ast` features have been deprecated in documentation since
1188-
Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at runtime
1189-
when they are accessed or used, and will be removed in Python 3.14:
1279+
* :mod:`ast`:
11901280

11911281
* :class:`!ast.Num`
11921282
* :class:`!ast.Str`
11931283
* :class:`!ast.Bytes`
11941284
* :class:`!ast.NameConstant`
11951285
* :class:`!ast.Ellipsis`
11961286

1197-
Use :class:`ast.Constant` instead.
1198-
(Contributed by Serhiy Storchaka in :gh:`90953`.)
1287+
* :mod:`asyncio`:
11991288

1200-
* :mod:`asyncio`: the *msg* parameter of both
1201-
:meth:`asyncio.Future.cancel` and
1202-
:meth:`asyncio.Task.cancel` (:gh:`90985`)
1289+
* :class:`!asyncio.MultiLoopChildWatcher`
1290+
* :class:`!asyncio.FastChildWatcher`
1291+
* :class:`!asyncio.AbstractChildWatcher`
1292+
* :class:`!asyncio.SafeChildWatcher`
1293+
* :func:`!asyncio.set_child_watcher`
1294+
* :func:`!asyncio.get_child_watcher`,
1295+
* :meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher`
1296+
* :meth:`!asyncio.AbstractEventLoopPolicy.get_child_watcher`
12031297

1204-
* :mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`.
1205-
Prefer :class:`Sequence` or :class:`collections.abc.Buffer`.
1206-
For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`.
1207-
(Contributed by Shantanu Jain in :gh:`91896`.)
1298+
* :mod:`collections.abc`: :class:`!collections.abc.ByteString`.
12081299

1209-
* :mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils.localtime`.
1210-
(Contributed by Alan Williams in :gh:`72346`.)
1300+
* :mod:`email`: the *isdst* parameter in :func:`email.utils.localtime`.
12111301

1212-
* :mod:`importlib.abc`: Deprecated the following classes, scheduled for removal in
1213-
Python 3.14:
1302+
* :mod:`importlib.abc`:
12141303

12151304
* :class:`!importlib.abc.ResourceReader`
12161305
* :class:`!importlib.abc.Traversable`
12171306
* :class:`!importlib.abc.TraversableResources`
12181307

1219-
Use :mod:`importlib.resources.abc` classes instead:
1308+
* :mod:`itertools`: Support for copy, deepcopy, and pickle operations.
12201309

1221-
* :class:`importlib.resources.abc.Traversable`
1222-
* :class:`importlib.resources.abc.TraversableResources`
1223-
1224-
(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)
1225-
1226-
* :mod:`itertools`: The module had undocumented, inefficient, historically buggy,
1227-
and inconsistent support for copy, deepcopy, and pickle operations.
1228-
This will be removed in 3.14 for a significant reduction in code
1229-
volume and maintenance burden.
1230-
(Contributed by Raymond Hettinger in :gh:`101588`.)
1310+
* :mod:`pkgutil`:
12311311

1232-
* :mod:`multiprocessing`: The default :mod:`multiprocessing` start method will change to a safer one on
1233-
Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is currently
1234-
the default (:gh:`84559`). Adding a runtime warning about this was deemed too
1235-
disruptive as the majority of code is not expected to care. Use the
1236-
:func:`~multiprocessing.get_context` or
1237-
:func:`~multiprocessing.set_start_method` APIs to explicitly specify when
1238-
your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`.
1312+
* :func:`!pkgutil.find_loader`
1313+
* :func:`!pkgutil.get_loader`.
12391314

1240-
* :mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader`
1241-
now raise :exc:`DeprecationWarning`;
1242-
use :func:`importlib.util.find_spec` instead.
1243-
(Contributed by Nikita Sobolev in :gh:`97850`.)
1315+
* :mod:`pty`:
12441316

1245-
* :mod:`pty`: The module has two undocumented ``master_open()`` and ``slave_open()``
1246-
functions that have been deprecated since Python 2 but only gained a
1247-
proper :exc:`DeprecationWarning` in 3.12. Remove them in 3.14.
1317+
* :func:`!pty.master_open`
1318+
* :func:`!pty.slave_open`
12481319

1249-
* :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree` is deprecated in 3.12,
1250-
and will be removed in 3.14.
1320+
* :mod:`shutil`: The *onerror* argument of :func:`shutil.rmtree`
12511321

1252-
* :mod:`typing`: :class:`typing.ByteString`, deprecated since Python 3.9, now causes a
1253-
:exc:`DeprecationWarning` to be emitted when it is used.
1322+
* :mod:`typing`: :class:`!typing.ByteString`
12541323

1255-
* :mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`xml.etree.ElementTree.Element`
1256-
is deprecated and will raise an exception in Python 3.14.
1324+
* :mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`xml.etree.ElementTree.Element`.
12571325

1258-
* ``__package__`` and ``__cached__`` will cease to be set or taken
1259-
into consideration by the import system (:gh:`97879`).
1326+
* The ``__package__`` and ``__cached__`` attributes on module objects.
12601327

1261-
* Accessing ``co_lnotab`` was deprecated in :pep:`626` since 3.10
1262-
and was planned to be removed in 3.12
1263-
but it only got a proper :exc:`DeprecationWarning` in 3.12.
1264-
May be removed in 3.14.
1265-
(Contributed by Nikita Sobolev in :gh:`101866`.)
1328+
* The ``co_lnotab`` attribute of code objects.
12661329

12671330
Pending Removal in Future Versions
12681331
----------------------------------

0 commit comments

Comments
 (0)