GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove `bool.__invert__` for 3.16 · Issue #149532 · python/cpython

Remove bool.__invert__ for 3.16 #149532

New issue
Copy link
New issue
Copy link
Open
Open
Remove bool.__invert__ for 3.16#149532
Copy link
Assignees
sobolevn
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@sobolevn
sobolevn
opened on May 8, 2026
Issue body actions

Feature or enhancement

It is scheduled for removal in 3.16:

cpython/Objects/boolobject.c

Lines 70 to 84 in 49918f5

static PyObject *
bool_invert(PyObject *v)
{
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"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 "
"underlying int.",
1) < 0) {
return NULL;
}
return PyLong_Type.tp_as_number->nb_invert(v);
}

Refs #103487
Refs #82012

Linked PRs

  • gh-149532: Remove bool.__invert__ magic method #149533
Reacted by Bartosz Sławecki

Activity

  1. sobolevn
    self-assigned this
    on May 8, 2026
  2. sobolevn
    added
    type-featureA feature request or enhancementA feature request or enhancement
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 8, 2026
  3. sobolevn
    added a commit that references this issue on May 8, 2026

    pythongh-149532: Remove `bool.__invert__` magic method

    d01f243
  4. serhiy-storchaka commented on May 8, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on May 8, 2026
    Member
    More actions

    Wait, was not deprecation reverted? See https://discuss.python.org/t/bool-deprecation/62232 .

  5. sobolevn commented on May 9, 2026

    @sobolevn
    sobolevn
    on May 9, 2026
    MemberAuthor
    More actions

    Oh, I've missed all this discussion, because it was never linked anywhere.
    I just followed the plan in Doc/deprecations/pending-removal-in-3.16.rst

    I guess that I will leave the PR open for now, while the discussion is ongoing.
    We can close / merge it when people will decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.