]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-122982: Extend the deprecation period for bool inversion by two years ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 25 Aug 2024 19:40:11 +0000 (21:40 +0200)
committerGitHub <noreply@github.com>
Sun, 25 Aug 2024 19:40:11 +0000 (19:40 +0000)
gh-122982: Extend the deprecation period for bool inversion by two years (GH-123306)
(cherry picked from commit 249b083ed8b3cfdff30bf578d7f9d3c5e982a4eb)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Doc/deprecations/pending-removal-in-3.16.rst
Doc/deprecations/pending-removal-in-future.rst
Doc/library/stdtypes.rst
Doc/whatsnew/3.12.rst
Misc/NEWS.d/next/Core and Builtins/2024-08-25-10-54-22.gh-issue-122982.KLD91q.rst [new file with mode: 0644]
Objects/boolobject.c

index 10cb5e424a623b4f1088346f7eb93c99a89e2126..82d400915768151923896e9861a5249237837f10 100644 (file)
@@ -5,6 +5,9 @@ Pending Removal in Python 3.16
   :class:`array.array` ``'u'`` type (:c:type:`wchar_t`):
   use the ``'w'`` type instead (``Py_UCS4``).
 
+* :mod:`builtins`:
+  ``~bool``, bitwise inversion on bool.
+
 * :mod:`symtable`:
   Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
   (Contributed by Bénédikt Tran in :gh:`119698`.)
index 7f10d9a98257f9ad5701f176d884a9bd84ddcb17..c5981593220a69e4bc6ffea7c9d3e24021b47bc1 100644 (file)
@@ -11,7 +11,6 @@ although there is currently no date scheduled for their removal.
 
 * :mod:`builtins`:
 
-  * ``~bool``, bitwise inversion on bool.
   * ``bool(NotImplemented)``.
   * Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)``
     signature is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead,
index 8e6cb11134f865195f4275c496918e470c45924a..8de93924f78ec9d1d5d334eec3f6380c52276a54 100644 (file)
@@ -832,7 +832,7 @@ over ``&``, ``|`` and ``^``.
 .. deprecated:: 3.12
 
    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
 many numeric contexts, ``False`` and ``True`` behave like the integers 0 and 1, respectively.
index 98d5b7a2c62b73221375121ec7fffb684dd581d5..329efd67088e6d981df880712e3b91ed616a2642 100644 (file)
@@ -1330,7 +1330,7 @@ Deprecated
   (Contributed by Brett Cannon in :gh:`65961`.)
 
 * 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
   ``int``, convert to int explicitly: ``~int(x)``. (Contributed by Tim Hoffmann
   in :gh:`103487`.)
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-08-25-10-54-22.gh-issue-122982.KLD91q.rst b/Misc/NEWS.d/next/Core and Builtins/2024-08-25-10-54-22.gh-issue-122982.KLD91q.rst
new file mode 100644 (file)
index 0000000..64882df
--- /dev/null
@@ -0,0 +1 @@
+Extend the deprecation period for bool inversion (``~``) by two years.
index f43e26f3f24e778150c5123acd059bacdbcd4668..74e16dd2700e4ae79d0327cfcf46cd18b7439046 100644 (file)
@@ -71,8 +71,8 @@ static PyObject *
 bool_invert(PyObject *v)
 {
     if (PyErr_WarnEx(PyExc_DeprecationWarning,
-                     "Bitwise inversion '~' on bool is deprecated. This "
-                     "returns the bitwise inversion of the underlying int "
+                     "Bitwise inversion '~' on bool is deprecated and will be removed in "
+                     "Python 3.16. This returns the bitwise inversion of the underlying int "
                      "object and is usually not what you expect from negating "
                      "a bool. Use the 'not' operator for boolean negation or "
                      "~int(x) if you really want the bitwise inversion of the "