GH-109975: Copyedit 3.13 What's New: New Deprecations (#123845)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Adam Turner 2024-09-16 18:03:46 +01:00 committed by GitHub
parent aba42c0b54
commit 05235e3c16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 251 additions and 164 deletions

View File

@ -1,57 +1,68 @@
Pending Removal in Python 3.15 Pending Removal in Python 3.15
------------------------------ ------------------------------
* :class:`http.server.CGIHTTPRequestHandler` will be removed along with its * :mod:`ctypes`:
related ``--cgi`` flag to ``python -m http.server``. It was obsolete and
rarely used. No direct replacement exists. *Anything* is better than CGI
to interface a web server with a request handler.
* :class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python 3.11 * The undocumented :func:`!ctypes.SetPointerType` function
and originally planned for removal in Python 3.13 (:gh:`90817`), has been deprecated since Python 3.13.
but removal has been postponed to Python 3.15.
Use :func:`locale.setlocale`, :func:`locale.getencoding` and * :mod:`http.server`:
:func:`locale.getlocale` instead.
(Contributed by Hugo van Kemenade in :gh:`111187`.) * The obsolete and rarely used :class:`~http.server.CGIHTTPRequestHandler`
has been deprecated since Python 3.13.
No direct replacement exists.
*Anything* is better than CGI to interface
a web server with a request handler.
* The :option:`!--cgi` flag to the :program:`python -m http.server`
command-line interface has been deprecated since Python 3.13.
* :class:`locale`:
* The :func:`~locale.getdefaultlocale` function
has been deprecated since Python 3.11.
Its removal was originally planned for Python 3.13 (:gh:`90817`),
but has been postponed to Python 3.15.
Use :func:`~locale.getlocale`, :func:`~locale.setlocale`,
and :func:`~locale.getencoding` instead.
(Contributed by Hugo van Kemenade in :gh:`111187`.)
* :mod:`pathlib`: * :mod:`pathlib`:
:meth:`pathlib.PurePath.is_reserved` is deprecated and scheduled for
removal in Python 3.15. Use :func:`os.path.isreserved` to detect reserved * :meth:`.PurePath.is_reserved`
paths on Windows. has been deprecated since Python 3.13.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
* :mod:`platform`: * :mod:`platform`:
:func:`~platform.java_ver` is deprecated and will be removed in 3.15.
It was largely untested, had a confusing API, * :func:`~platform.java_ver` has been deprecated since Python 3.13.
and was only useful for Jython support. This function is only useful for Jython support, has a confusing API,
(Contributed by Nikita Sobolev in :gh:`116349`.) and is largely untested.
* :mod:`threading`: * :mod:`threading`:
Passing any arguments to :func:`threading.RLock` is now deprecated.
C version allows any numbers of args and kwargs,
but they are just ignored. Python version does not allow any arguments.
All arguments will be removed from :func:`threading.RLock` in Python 3.15.
(Contributed by Nikita Sobolev in :gh:`102029`.)
* :class:`typing.NamedTuple`: * :func:`~threading.RLock` will take no arguments in Python 3.15.
Passing any arguments has been deprecated since Python 3.14,
as the Python version does not permit any arguments,
but the C version allows any number of positional or keyword arguments,
ignoring every argument.
* The undocumented keyword argument syntax for creating :class:`!NamedTuple` classes * :mod:`typing`:
(``NT = NamedTuple("NT", x=int)``) is deprecated, and will be disallowed in
3.15. Use the class-based syntax or the functional syntax instead.
* When using the functional syntax to create a :class:`!NamedTuple` class, failing to * The undocumented keyword argument syntax for creating
pass a value to the *fields* parameter (``NT = NamedTuple("NT")``) is :class:`~typing.NamedTuple` classes
deprecated. Passing ``None`` to the *fields* parameter (e.g. ``Point = NamedTuple("Point", x=int, y=int)``)
(``NT = NamedTuple("NT", None)``) is also deprecated. Both will be has been deprecated since Python 3.13.
disallowed in Python 3.15. To create a :class:`!NamedTuple` class with 0 fields, use Use the class-based syntax or the functional syntax instead.
``class NT(NamedTuple): pass`` or ``NT = NamedTuple("NT", [])``.
* :class:`typing.TypedDict`: When using the functional syntax to create a * The :func:`typing.no_type_check_decorator` decorator function
:class:`!TypedDict` class, failing to pass a value to the *fields* parameter (``TD = has been deprecated since Python 3.13.
TypedDict("TD")``) is deprecated. Passing ``None`` to the *fields* parameter After eight years in the :mod:`typing` module,
(``TD = TypedDict("TD", None)``) is also deprecated. Both will be disallowed it has yet to be supported by any major type checker.
in Python 3.15. To create a :class:`!TypedDict` class with 0 fields, use ``class
TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.
* :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` * :mod:`wave`:
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes.
They will be removed in Python 3.15. * The :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`,
(Contributed by Victor Stinner in :gh:`105096`.) and :meth:`~wave.Wave_read.getmarkers` methods of
the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes
have been deprecated since Python 3.13.

View File

@ -1,18 +1,42 @@
Pending Removal in Python 3.16 Pending Removal in Python 3.16
------------------------------ ------------------------------
* :mod:`array`:
:class:`array.array` ``'u'`` type (:c:type:`wchar_t`):
use the ``'w'`` type instead (``Py_UCS4``).
* :mod:`builtins`: * :mod:`builtins`:
``~bool``, bitwise inversion on bool.
* Bitwise inversion on boolean types, ``~True`` or ``~False``
has been deprecated since Python 3.12,
as it produces surprising and unintuitive results (``-2`` and ``-1``).
Use ``not x`` instead for the logical negation of a Boolean.
In the rare case that you need the bitwise inversion of
the underlying integer, convert to ``int`` explicitly (``~int(x)``).
* :mod:`array`:
* The ``'u'`` format code (:c:type:`wchar_t`)
has been deprecated in documentation since Python 3.3
and at runtime since Python 3.13.
Use the ``'w'`` format code (:c:type:`Py_UCS4`)
for Unicode characters instead.
* :mod:`shutil`:
* The :class:`!ExecError` exception
has been deprecated since Python 3.14.
It has not been used by any function in :mod:`!shutil` since Python 3.4,
and is now an alias of :exc:`RuntimeError`.
* :mod:`symtable`: * :mod:`symtable`:
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
(Contributed by Bénédikt Tran in :gh:`119698`.)
* :mod:`shutil`: Deprecate :class:`!shutil.ExecError`, which hasn't * The :meth:`Class.get_methods <symtable.Class.get_methods>` method
been raised by any :mod:`!shutil` function since Python 3.4. It's has been deprecated since Python 3.14.
now an alias for :exc:`RuntimeError`.
* :mod:`sys`:
* The :func:`~sys._enablelegacywindowsfsencoding` function
has been deprecated since Python 3.13.
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
* :mod:`tarfile`:
* The undocumented and unused :attr:`!TarFile.tarfile` attribute
has been deprecated since Python 3.13.

View File

@ -1644,6 +1644,10 @@ builtins
the :attr:`!__wrapped__` attribute that was added in Python 3.10. the :attr:`!__wrapped__` attribute that was added in Python 3.10.
(Contributed by Raymond Hettinger in :gh:`89519`.) (Contributed by Raymond Hettinger in :gh:`89519`.)
* Raise a :exc:`RuntimeError` when calling :meth:`frame.clear`
on a suspended frame (as has always been the case for an executing frame).
(Contributed by Irit Katriel in :gh:`79932`.)
configparser configparser
------------ ------------
@ -1784,151 +1788,199 @@ webbrowser
New Deprecations New Deprecations
================ ================
* :mod:`array`: :mod:`array`'s ``'u'`` format code, deprecated in docs since Python 3.3, * :ref:`User-defined functions <user-defined-funcs>`:
emits :exc:`DeprecationWarning` since 3.13
and will be removed in Python 3.16.
Use the ``'w'`` format code instead.
(Contributed by Hugo van Kemenade in :gh:`80480`.)
* :mod:`ctypes`: Deprecate undocumented :func:`!ctypes.SetPointerType` * Deprecate assignment to a function's :attr:`~function.__code__` attribute,
function. :term:`Soft-deprecate <soft deprecated>` the :func:`ctypes.ARRAY` where the new code object's type does not match the function's type.
function in favor of multiplication. The different types are:
(Contributed by Victor Stinner in :gh:`105733`.) plain function, generator, async generator, and coroutine.
(Contributed by Irit Katriel in :gh:`81137`.)
* :mod:`decimal`: Deprecate non-standard format specifier "N" for * :mod:`array`:
:class:`decimal.Decimal`.
It was not documented and only supported in the C implementation.
(Contributed by Serhiy Storchaka in :gh:`89902`.)
* :mod:`dis`: The ``dis.HAVE_ARGUMENT`` separator is deprecated. Check * Deprecate the ``'u'`` format code (:c:type:`wchar_t`) at runtime.
membership in :data:`~dis.hasarg` instead. This format code has been deprecated in documentation since Python 3.3,
(Contributed by Irit Katriel in :gh:`109319`.) and will be removed in Python 3.16.
Use the ``'w'`` format code (:c:type:`Py_UCS4`)
for Unicode characters instead.
(Contributed by Hugo van Kemenade in :gh:`80480`.)
* :ref:`frame-objects`: * :mod:`ctypes`:
Calling :meth:`frame.clear` on a suspended frame raises :exc:`RuntimeError`
(as has always been the case for an executing frame).
(Contributed by Irit Katriel in :gh:`79932`.)
* :mod:`getopt` and :mod:`optparse` modules: They are now * Deprecate the undocumented :func:`!SetPointerType` function,
:term:`soft deprecated`: the :mod:`argparse` module should be used for new projects. to be removed in Python 3.15.
Previously, the :mod:`optparse` module was already deprecated, its removal (Contributed by Victor Stinner in :gh:`105733`.)
was not scheduled, and no warnings was emitted: so there is no change in
practice.
(Contributed by Victor Stinner in :gh:`106535`.)
* :mod:`gettext`: Emit deprecation warning for non-integer numbers in * :term:`Soft-deprecate <soft deprecated>` the :func:`~ctypes.ARRAY`
:mod:`gettext` functions and methods that consider plural forms even if the function in favour of ``type * length`` multiplication.
translation was not found. (Contributed by Victor Stinner in :gh:`105733`.)
(Contributed by Serhiy Storchaka in :gh:`88434`.)
* :mod:`glob`: The undocumented :func:`!glob.glob0` and :func:`!glob.glob1` * :mod:`decimal`:
functions are deprecated. Use :func:`glob.glob` and pass a directory to its
*root_dir* argument instead.
(Contributed by Barney Gale in :gh:`117337`.)
* :mod:`http.server`: :class:`http.server.CGIHTTPRequestHandler` now emits a * Deprecate the non-standard and undocumented :class:`~decimal.Decimal`
:exc:`DeprecationWarning` as it will be removed in 3.15. Process-based CGI format specifier ``'N'``,
HTTP servers have been out of favor for a very long time. This code was which is only supported in the :mod:`!decimal` module's C implementation.
outdated, unmaintained, and rarely used. It has a high potential for both (Contributed by Serhiy Storchaka in :gh:`89902`.)
security and functionality bugs. This includes removal of the ``--cgi``
flag to the ``python -m http.server`` command line in 3.15.
* :mod:`mimetypes`: Passing file path instead of URL in :func:`~mimetypes.guess_type` is * :mod:`dis`:
:term:`soft deprecated`. Use :func:`~mimetypes.guess_file_type` instead.
(Contributed by Serhiy Storchaka in :gh:`66543`.)
* :mod:`re`: Passing optional arguments *maxsplit*, *count* and *flags* in module-level * Deprecate the :attr:`!HAVE_ARGUMENT` separator.
functions :func:`re.split`, :func:`re.sub` and :func:`re.subn` as positional Check membership in :data:`~dis.hasarg` instead.
arguments is now deprecated. In future Python versions these parameters will be (Contributed by Irit Katriel in :gh:`109319`.)
:ref:`keyword-only <keyword-only_parameter>`.
(Contributed by Serhiy Storchaka in :gh:`56166`.) * :mod:`getopt` and :mod:`optparse`:
* Both modules are now :term:`soft deprecated`,
with :mod:`argparse` preferred for new projects.
This is a new soft-deprecation for the :mod:`!getopt` module,
whereas the :mod:`!optparse` module was already *de facto* soft deprecated.
(Contributed by Victor Stinner in :gh:`106535`.)
* :mod:`gettext`:
* Deprecate non-integer numbers as arguments to functions and methods
that consider plural forms in the :mod:`!gettext` module,
even if no translation was found.
(Contributed by Serhiy Storchaka in :gh:`88434`.)
* :mod:`glob`:
* Deprecate the undocumented :func:`!glob0` and :func:`!glob1` functions.
Use :func:`~glob.glob` and pass a :term:`path-like object` specifying
the root directory to the *root_dir* parameter instead.
(Contributed by Barney Gale in :gh:`117337`.)
* :mod:`http.server`:
* Deprecate :class:`~http.server.CGIHTTPRequestHandler`,
to be removed in Python 3.15.
Process-based CGI HTTP servers have been out of favor for a very long time.
This code was outdated, unmaintained, and rarely used.
It has a high potential for both security and functionality bugs.
(Contributed by Gregory P. Smith in :gh:`109096`.)
* Deprecate the :option:`!--cgi` flag to
the :program:`python -m http.server` command-line interface,
to be removed in Python 3.15.
(Contributed by Gregory P. Smith in :gh:`109096`.)
* :mod:`mimetypes`:
* :term:`Soft-deprecate <soft deprecated>` file path arguments
to :func:`~mimetypes.guess_type`,
use :func:`~mimetypes.guess_file_type` instead.
(Contributed by Serhiy Storchaka in :gh:`66543`.)
* :mod:`re`:
* Deprecate passing the optional *maxsplit*, *count*, or *flags* arguments
as positional arguments to the module-level
:func:`~re.split`, :func:`~re.sub`, and :func:`~re.subn` functions.
These parameters will become :ref:`keyword-only <keyword-only_parameter>`
in a future version of Python.
(Contributed by Serhiy Storchaka in :gh:`56166`.)
* :mod:`pathlib`: * :mod:`pathlib`:
:meth:`pathlib.PurePath.is_reserved` is deprecated and scheduled for
removal in Python 3.15. Use :func:`os.path.isreserved` to detect reserved * Deprecate :meth:`.PurePath.is_reserved`,
paths on Windows. to be removed in Python 3.15.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
(Contributed by Barney Gale in :gh:`88569`.)
* :mod:`platform`: * :mod:`platform`:
:func:`~platform.java_ver` is deprecated and will be removed in 3.15.
It was largely untested, had a confusing API,
and was only useful for Jython support.
(Contributed by Nikita Sobolev in :gh:`116349`.)
* :mod:`pydoc`: Deprecate undocumented :func:`!pydoc.ispackage` function. * Deprecate :func:`~platform.java_ver`,
(Contributed by Zackery Spytz in :gh:`64020`.) to be removed in Python 3.15.
This function is only useful for Jython support, has a confusing API,
and is largely untested.
(Contributed by Nikita Sobolev in :gh:`116349`.)
* :mod:`sqlite3`: Passing more than one positional argument to * :mod:`pydoc`:
:func:`sqlite3.connect` and the :class:`sqlite3.Connection` constructor is
deprecated. The remaining parameters will become keyword-only in Python 3.15.
Deprecate passing name, number of arguments, and the callable as keyword * Deprecate the undocumented :func:`!ispackage` function.
arguments for the following :class:`sqlite3.Connection` APIs: (Contributed by Zackery Spytz in :gh:`64020`.)
* :meth:`~sqlite3.Connection.create_function` * :mod:`sqlite3`:
* :meth:`~sqlite3.Connection.create_aggregate`
Deprecate passing the callback callable by keyword for the following * Deprecate passing more than one positional argument to
:class:`sqlite3.Connection` APIs: the :func:`~sqlite3.connect` function
and the :class:`~sqlite3.Connection` constructor.
The remaining parameters will become keyword-only in Python 3.15.
(Contributed by Erlend E. Aasland in :gh:`107948`.)
* :meth:`~sqlite3.Connection.set_authorizer` * Deprecate passing name, number of arguments, and the callable as keyword
* :meth:`~sqlite3.Connection.set_progress_handler` arguments for :meth:`.Connection.create_function`
* :meth:`~sqlite3.Connection.set_trace_callback` and :meth:`.Connection.create_aggregate`
These parameters will become positional-only in Python 3.15.
(Contributed by Erlend E. Aasland in :gh:`108278`.)
The affected parameters will become positional-only in Python 3.15. * Deprecate passing the callback callable by keyword for the
:meth:`~sqlite3.Connection.set_authorizer`,
:meth:`~sqlite3.Connection.set_progress_handler`, and
:meth:`~sqlite3.Connection.set_trace_callback`
:class:`~sqlite3.Connection` methods.
The callback callables will become positional-only in Python 3.15.
(Contributed by Erlend E. Aasland in :gh:`108278`.)
(Contributed by Erlend E. Aasland in :gh:`107948` and :gh:`108278`.) * :mod:`sys`:
* :mod:`sys`: The :func:`sys._enablelegacywindowsfsencoding` function is deprecated. * Deprecate the :func:`~sys._enablelegacywindowsfsencoding` function,
Replace it with the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable. to be removed in Python 3.16.
(Contributed by Inada Naoki in :gh:`73427`.) Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
(Contributed by Inada Naoki in :gh:`73427`.)
* :mod:`tarfile`: * :mod:`tarfile`:
The undocumented and unused ``tarfile`` attribute of :class:`tarfile.TarFile`
is deprecated and scheduled for removal in Python 3.16.
* :mod:`traceback`: The field *exc_type* of :class:`traceback.TracebackException` * Deprecate the undocumented and unused :attr:`!TarFile.tarfile` attribute,
is deprecated. Use *exc_type_str* instead. to be removed in Python 3.16.
(Contributed in :gh:`115256`.)
* :mod:`traceback`:
* Deprecate the :attr:`.TracebackException.exc_type` attribute.
Use :attr:`.TracebackException.exc_type_str` instead.
(Contributed by Irit Katriel in :gh:`112332`.)
* :mod:`typing`: * :mod:`typing`:
* Creating a :class:`typing.NamedTuple` class using keyword arguments to denote * Deprecate the undocumented keyword argument syntax for creating
the fields (``NT = NamedTuple("NT", x=int, y=int)``) is deprecated, and will :class:`~typing.NamedTuple` classes
be disallowed in Python 3.15. Use the class-based syntax or the functional (e.g. ``Point = NamedTuple("Point", x=int, y=int)``),
syntax instead. (Contributed by Alex Waygood in :gh:`105566`.) to be removed in Python 3.15.
Use the class-based syntax or the functional syntax instead.
(Contributed by Alex Waygood in :gh:`105566`.)
* When using the functional syntax to create a :class:`typing.NamedTuple` * Deprecate omitting the *fields* parameter when creating
class or a :class:`typing.TypedDict` class, failing to pass a value to the a :class:`~typing.NamedTuple` or :class:`typing.TypedDict` class,
'fields' parameter (``NT = NamedTuple("NT")`` or ``TD = TypedDict("TD")``) is and deprecate passing ``None`` to the *fields* parameter of both types.
deprecated. Passing ``None`` to the 'fields' parameter Python 3.15 will require a valid sequence for the *fields* parameter.
(``NT = NamedTuple("NT", None)`` or ``TD = TypedDict("TD", None)``) is also To create a NamedTuple class with zero fields,
deprecated. Both will be disallowed in Python 3.15. To create a NamedTuple use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple("NT", ())``.
class with zero fields, use ``class NT(NamedTuple): pass`` or To create a TypedDict class with zero fields,
``NT = NamedTuple("NT", [])``. To create a TypedDict class with zero fields, use use ``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.
``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.
(Contributed by Alex Waygood in :gh:`105566` and :gh:`105570`.) (Contributed by Alex Waygood in :gh:`105566` and :gh:`105570`.)
* :func:`typing.no_type_check_decorator` is deprecated, and scheduled for * Deprecate the :func:`typing.no_type_check_decorator` decorator function,
removal in Python 3.15. After eight years in the :mod:`typing` module, it to be removed in in Python 3.15.
has yet to be supported by any major type checkers. After eight years in the :mod:`typing` module,
it has yet to be supported by any major type checker.
(Contributed by Alex Waygood in :gh:`106309`.) (Contributed by Alex Waygood in :gh:`106309`.)
* :data:`typing.AnyStr` is deprecated. In Python 3.16, it will be removed from * Deprecate :data:`typing.AnyStr`.
``typing.__all__``, and a :exc:`DeprecationWarning` will be emitted when it In Python 3.16, it will be removed from ``typing.__all__``,
is imported or accessed. It will be removed entirely in Python 3.18. Use and a :exc:`DeprecationWarning` will be emitted at runtime
the new :ref:`type parameter syntax <type-params>` instead. when it is imported or accessed.
It will be removed entirely in Python 3.18.
Use the new :ref:`type parameter syntax <type-params>` instead.
(Contributed by Michael The in :gh:`107116`.) (Contributed by Michael The in :gh:`107116`.)
* :ref:`user-defined-funcs`: * :mod:`wave`:
Assignment to a function's :attr:`~function.__code__` attribute where the new code
object's type does not match the function's type is deprecated. The
different types are: plain function, generator, async generator and
coroutine.
(Contributed by Irit Katriel in :gh:`81137`.)
* :mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` * Deprecate the :meth:`~wave.Wave_read.getmark`, :meth:`!setmark`,
methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. and :meth:`~wave.Wave_read.getmarkers` methods of
They will be removed in Python 3.15. the :class:`~wave.Wave_read` and :class:`~wave.Wave_write` classes,
(Contributed by Victor Stinner in :gh:`105096`.) to be removed in Python 3.15.
(Contributed by Victor Stinner in :gh:`105096`.)
.. Add deprecations above alphabetically, not here at the end. .. Add deprecations above alphabetically, not here at the end.
@ -1943,10 +1995,10 @@ New Deprecations
CPython Bytecode Changes CPython Bytecode Changes
======================== ========================
* The oparg of ``YIELD_VALUE`` is now ``1`` if the yield is part of a * The oparg of :opcode:`YIELD_VALUE` is now
yield-from or await, and ``0`` otherwise. The oparg of ``RESUME`` was ``1`` if the yield is part of a yield-from or await, and ``0`` otherwise.
changed to add a bit indicating whether the except-depth is 1, which The oparg of :opcode:`RESUME` was changed to add a bit indicating
is needed to optimize closing of generators. if the except-depth is 1, which is needed to optimize closing of generators.
(Contributed by Irit Katriel in :gh:`111354`.) (Contributed by Irit Katriel in :gh:`111354`.)