Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend deprecation warning period for bitwise inversion on bool type #122982

Closed
Eclips4 opened this issue Aug 13, 2024 · 8 comments
Closed

Extend deprecation warning period for bitwise inversion on bool type #122982

Eclips4 opened this issue Aug 13, 2024 · 8 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@Eclips4
Copy link
Member

Eclips4 commented Aug 13, 2024

Feature or enhancement

Proposal:

Since Python 3.12, attempting to use bitwise inversion on a bool type is raises a DeprecationWarning:

Python 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = True
>>> ~a
<stdin>:1: DeprecationWarning: Bitwise inversion '~' on bool is deprecated. 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.
-2
>>>

I have a PR ready.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@Eclips4 Eclips4 added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 13, 2024
@Eclips4 Eclips4 self-assigned this Aug 13, 2024
@encukou
Copy link
Member

encukou commented Aug 14, 2024

It's deprecated, but why should it be removed now?

@encukou
Copy link
Member

encukou commented Aug 14, 2024

Oh, I see the plan to remove it in 3.14 is in the docs, but not all the places it should be :(

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Aug 24, 2024

I think the removal might affect a number of users (e.g. see comments on #103487); I'd vote for extending the deprecation period beyond the 2 year minimum

@Eclips4
Copy link
Member Author

Eclips4 commented Aug 25, 2024

I think the removal might affect a number of users (e.g. see comments on #103487); I'd vote for extending the deprecation period beyond the 2 year minimum

I've read these comments and I agree with your opinion. I'll close the PR and open a new one to properly document the deprecation.

@serhiy-storchaka
Copy link
Member

It is not necessary to close the PR. It can simply be postponed for few years.

@picnixz picnixz changed the title Prohibit bitwise inversion on bool type Extend deprecation warning for bitwise inversion on bool type Aug 25, 2024
@picnixz picnixz changed the title Extend deprecation warning for bitwise inversion on bool type Extend deprecation warning period for bitwise inversion on bool type Aug 25, 2024
@picnixz
Copy link
Member

picnixz commented Aug 25, 2024

I've changed the title of the issue to highlight the fact that we are not removing it for now. We will change it later when we'll eventually remove it (just for tracking purposes)

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 25, 2024
…two years (pythonGH-123306)

(cherry picked from commit 249b083)

Co-authored-by: Kirill Podoprigora <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 25, 2024
…two years (pythonGH-123306)

(cherry picked from commit 249b083)

Co-authored-by: Kirill Podoprigora <[email protected]>
hauntsaninja pushed a commit that referenced this issue Aug 25, 2024
… two years (GH-123306) (#123317)

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]>
hauntsaninja pushed a commit that referenced this issue Aug 25, 2024
… 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]>
@nineteendo
Copy link
Contributor

Can't this be closed now?

@picnixz
Copy link
Member

picnixz commented Sep 26, 2024

Mmmh. Yes. We'll open another issue if we want to really deprecate the behaviour.

@picnixz picnixz closed this as completed Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

6 participants