Skip to content

None is not a valid value for ast.ImportFrom.level #92986

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

Closed
hauntsaninja opened this issue May 19, 2022 · 1 comment
Closed

None is not a valid value for ast.ImportFrom.level #92986

hauntsaninja opened this issue May 19, 2022 · 1 comment
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@hauntsaninja
Copy link
Contributor

hauntsaninja commented May 19, 2022

For example:

import ast
tree = ast.parse("from x import y")
tree.body[0].level = None
ast.unparse(tree)  # raises

This is very similar to https://bugs.python.org/issue46289 and #30467 cc @isidentical

Note the compiler does seem to allow it, but it's always an int in practice and documented as such

Discovered in typeshed.

@hauntsaninja hauntsaninja added the type-bug An unexpected behavior, bug, or error label May 19, 2022
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 19, 2022
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 19, 2022
This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(python#57645, python#92987)
@AA-Turner AA-Turner added the stdlib Python modules in the Lib dir label May 23, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 5, 2022
…GH-92992)

This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(pythonGH-57645, pythonGH-92987)
(cherry picked from commit 200c9a8)

Co-authored-by: Shantanu <[email protected]>
isidentical pushed a commit that referenced this issue Sep 5, 2022
This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(#57645, #92987)
isidentical pushed a commit to isidentical/cpython that referenced this issue Sep 5, 2022
…ythonGH-92992)

This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(pythonGH-57645, pythonGH-92987)
(cherry picked from commit 200c9a8)

Co-authored-by: Shantanu <[email protected]>
miss-islington added a commit that referenced this issue Sep 5, 2022
This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(GH-57645, GH-92987)
(cherry picked from commit 200c9a8)

Co-authored-by: Shantanu <[email protected]>
isidentical added a commit that referenced this issue Sep 6, 2022
) (GH-96593)

This doesn't happen naturally, but is allowed by the ASDL and compiler.
We don't want to change ASDL for backward compatibility reasons
(GH-57645, GH-92987)
(cherry picked from commit 200c9a8)

Co-authored-by: Shantanu <[email protected]>

Co-authored-by: Shantanu <[email protected]>
@isidentical
Copy link
Member

Thanks for the fix @hauntsaninja.

@isidentical isidentical self-assigned this Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants