GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-122982: Prohibit bitwise inversion on bool type by Eclips4 · Pull Request #122983 · python/cpython Conversation
|
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| * :mod:`builtins`: | ||
|
|
||
| * ``~bool``, bitwise inversion on bool. |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If this gets merged, you should open a new PR to move this note to the 3.14 pending removals & backport that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Just wondering: what if simply set PyBool_Type.tp_as_number->nb_invert = NULL in _PyTypes_InitTypes()?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yeah, this works. Do you think it's worth doing or should we continue with the current approach? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I do not know. How does On one hand, using the same code to generate error messages guarantees that there is no difference in error messages. On other hand, we may want to have a different error message, for example add a suggestion about |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Python 3.14.0a0 (heads/remove_bool_invert-dirty:4760de8ecbb, Aug 16 2024, 09:24:28) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> True.__invert__() -2 So, this is a wrong approach.
That's sounds good. I'll add a suggestion and tests for it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I don't click merge, because @encukou's comment here: #122983 (review) seems like it is better to wait for resolution.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Wordsmithing: We seem to use "Maybe you meant" for SyntaxErrors, with "Did you mean" used more generally. Non-blocking suggestion though.
A
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Adam Turner <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this on the issue, but I think in this case we should extend the deprecation period beyond the minimum #122982 (comment)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return PyLong_Type.tp_as_number->nb_invert(v); | ||
| PyErr_SetString( | ||
| PyExc_TypeError, | ||
| "bad operand type for unary ~: 'bool'. Did you mean 'not' instead of '~'?" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think the text in the warning was helpful, especially since the previous behaviour has been around forever.
Maybe something like:
bad operand type for unary ~: 'bool'. Did you mean 'not' instead of '~'? Use 'not x' for boolean negation and '~int(x)` in the rare case you want bitwise inversion of the underlying int"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing per #122982 (comment) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.