-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Improve AST validation for Constant nodes #84181
Comments
When something that isn't constant found in a ast.Constant node's body, python reports errors like this >>> e = ast.Expression(body=ast.Constant(value=type))
>>> ast.fix_missing_locations(e)
<_ast.Expression object at 0x7fc2c23981c0>
>>> compile(e, "<test>", "eval")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: got an invalid type in Constant: type But if something is part of constant tuple and frozenset isn't constant, the error reporting is wrong >>> e = ast.Expression(body=ast.Constant(value=(1,2,type)))
>>> compile(e, "<test>", "eval")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: got an invalid type in Constant: tuple This should've been TypeError: got an invalid type in Constant: type |
You got an anniversary issue! |
Congratulations Batuhan! You win with the bug number 40000! A nice number ;-) To be honest, I wanted to get it, but I didn't want to cheat by opening a stupid issue. |
sorry to take it Victor, maybe you can get the perfect issue number when we migrate to github? |
Why truncating the type name in the error message? The qualified name (don't call _PyType_Name()) should provide more information, no? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: