mirror of https://github.com/python/cpython
[3.13] gh-122982: Extend the deprecation period for bool inversion by two years (GH-123306) (#123316)
gh-122982: Extend the deprecation period for bool inversion by two years (GH-123306)
(cherry picked from commit 249b083ed8
)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
parent
3b7e5b640f
commit
abaaaff328
|
@ -5,6 +5,9 @@ Pending Removal in Python 3.16
|
||||||
:class:`array.array` ``'u'`` type (:c:type:`wchar_t`):
|
:class:`array.array` ``'u'`` type (:c:type:`wchar_t`):
|
||||||
use the ``'w'`` type instead (``Py_UCS4``).
|
use the ``'w'`` type instead (``Py_UCS4``).
|
||||||
|
|
||||||
|
* :mod:`builtins`:
|
||||||
|
``~bool``, bitwise inversion on bool.
|
||||||
|
|
||||||
* :mod:`symtable`:
|
* :mod:`symtable`:
|
||||||
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
|
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
|
||||||
(Contributed by Bénédikt Tran in :gh:`119698`.)
|
(Contributed by Bénédikt Tran in :gh:`119698`.)
|
||||||
|
|
|
@ -11,7 +11,6 @@ although there is currently no date scheduled for their removal.
|
||||||
|
|
||||||
* :mod:`builtins`:
|
* :mod:`builtins`:
|
||||||
|
|
||||||
* ``~bool``, bitwise inversion on bool.
|
|
||||||
* ``bool(NotImplemented)``.
|
* ``bool(NotImplemented)``.
|
||||||
* Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)``
|
* Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)``
|
||||||
signature is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead,
|
signature is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead,
|
||||||
|
|
|
@ -832,7 +832,7 @@ over ``&``, ``|`` and ``^``.
|
||||||
.. deprecated:: 3.12
|
.. deprecated:: 3.12
|
||||||
|
|
||||||
The use of the bitwise inversion operator ``~`` is deprecated and will
|
The use of the bitwise inversion operator ``~`` is deprecated and will
|
||||||
raise an error in Python 3.14.
|
raise an error in Python 3.16.
|
||||||
|
|
||||||
:class:`bool` is a subclass of :class:`int` (see :ref:`typesnumeric`). In
|
:class:`bool` is a subclass of :class:`int` (see :ref:`typesnumeric`). In
|
||||||
many numeric contexts, ``False`` and ``True`` behave like the integers 0 and 1, respectively.
|
many numeric contexts, ``False`` and ``True`` behave like the integers 0 and 1, respectively.
|
||||||
|
|
|
@ -1319,7 +1319,7 @@ Deprecated
|
||||||
(Contributed by Brett Cannon in :gh:`65961`.)
|
(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.16. 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: ``~int(x)``. (Contributed by Tim Hoffmann
|
``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
|
||||||
in :gh:`103487`.)
|
in :gh:`103487`.)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Extend the deprecation period for bool inversion (``~``) by two years.
|
|
@ -71,8 +71,8 @@ static PyObject *
|
||||||
bool_invert(PyObject *v)
|
bool_invert(PyObject *v)
|
||||||
{
|
{
|
||||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
"Bitwise inversion '~' on bool is deprecated. This "
|
"Bitwise inversion '~' on bool is deprecated and will be removed in "
|
||||||
"returns the bitwise inversion of the underlying int "
|
"Python 3.16. This returns the bitwise inversion of the underlying int "
|
||||||
"object and is usually not what you expect from negating "
|
"object and is usually not what you expect from negating "
|
||||||
"a bool. Use the 'not' operator for boolean negation or "
|
"a bool. Use the 'not' operator for boolean negation or "
|
||||||
"~int(x) if you really want the bitwise inversion of the "
|
"~int(x) if you really want the bitwise inversion of the "
|
||||||
|
|
Loading…
Reference in New Issue