Skip to content

Commit abaaaff

Browse files
[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 249b083) Co-authored-by: Kirill Podoprigora <[email protected]>
1 parent 3b7e5b6 commit abaaaff

File tree

6 files changed

+8
-5
lines changed

6 files changed

+8
-5
lines changed

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Pending Removal in Python 3.16
55
:class:`array.array` ``'u'`` type (:c:type:`wchar_t`):
66
use the ``'w'`` type instead (``Py_UCS4``).
77

8+
* :mod:`builtins`:
9+
``~bool``, bitwise inversion on bool.
10+
811
* :mod:`symtable`:
912
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
1013
(Contributed by Bénédikt Tran in :gh:`119698`.)

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ although there is currently no date scheduled for their removal.
1111

1212
* :mod:`builtins`:
1313

14-
* ``~bool``, bitwise inversion on bool.
1514
* ``bool(NotImplemented)``.
1615
* Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)``
1716
signature is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead,

Doc/library/stdtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ over ``&``, ``|`` and ``^``.
832832
.. deprecated:: 3.12
833833

834834
The use of the bitwise inversion operator ``~`` is deprecated and will
835-
raise an error in Python 3.14.
835+
raise an error in Python 3.16.
836836

837837
:class:`bool` is a subclass of :class:`int` (see :ref:`typesnumeric`). In
838838
many numeric contexts, ``False`` and ``True`` behave like the integers 0 and 1, respectively.

Doc/whatsnew/3.12.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ Deprecated
13191319
(Contributed by Brett Cannon in :gh:`65961`.)
13201320

13211321
* The bitwise inversion operator (``~``) on bool is deprecated. It will throw an
1322-
error in Python 3.14. Use ``not`` for logical negation of bools instead.
1322+
error in Python 3.16. Use ``not`` for logical negation of bools instead.
13231323
In the rare case that you really need the bitwise inversion of the underlying
13241324
``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
13251325
in :gh:`103487`.)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Extend the deprecation period for bool inversion (``~``) by two years.

Objects/boolobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ static PyObject *
7171
bool_invert(PyObject *v)
7272
{
7373
if (PyErr_WarnEx(PyExc_DeprecationWarning,
74-
"Bitwise inversion '~' on bool is deprecated. This "
75-
"returns the bitwise inversion of the underlying int "
74+
"Bitwise inversion '~' on bool is deprecated and will be removed in "
75+
"Python 3.16. This returns the bitwise inversion of the underlying int "
7676
"object and is usually not what you expect from negating "
7777
"a bool. Use the 'not' operator for boolean negation or "
7878
"~int(x) if you really want the bitwise inversion of the "

0 commit comments

Comments
 (0)