-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
~bool
deprecation not reported for literals
#134280
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
Comments
It seems to warn for me on 3.15 and 3.14:
This is 3.13 only. |
@StanFromIreland I ran it in a container (https://hub.docker.com/_/python/) on 3.14 for reproducibility:
On 3.15 in debug mode, I do get a warning:
EDIT: seems like the warning is displayed in 3.13 and 3.14 if the |
cc @timhoffm |
I will look into this. |
This works as intended. By default, DeprecationWarning is only reported for the Run Python with |
So in this case, the operation is considered to be in the if __name__ == "__main__":
a = True
print(~a) # prints -2, with DeprecationWarning but here it's considered to be outside of if __name__ == "__main__":
print(~True) # prints -2, no DeprecationWarning (from the docs (https://docs.python.org/3/library/exceptions.html#DeprecationWarning) and PEP 565 I'm assuming that you meant that deprecation warnings are only active in
) |
Well, this is obviously related to the fact that If warnings are ignored in the constant folding, this is a bug. |
This moves the deprecation warning from compile time to runtime.
#134982 disables constant folding for Ideally, we could also emit a SyntaxWarning at compile time, like we do for We narrowly avoided a bullet with |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
Related to: #103487
A DeprecationWarning is reported for
var.py
, but not forliteral.py
.What's interesting is that there's a test for this:
cpython/Lib/test/test_bool.py
Lines 68 to 71 in 42d03f3
eval("~True")
is used instead of just~True
CPython versions tested on:
CPython main branch, 3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: