[3.11] gh-92986: Fix ast.unparse when ImportFrom.level is None (GH-92992) (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 200c9a8da0)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
Batuhan Taskaya 2022-09-06 13:23:26 +03:00 committed by GitHub
parent 08d8058b79
commit a0848d169b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View file

@ -852,7 +852,7 @@ class _Unparser(NodeVisitor):
def visit_ImportFrom(self, node):
self.fill("from ")
self.write("." * node.level)
self.write("." * (node.level or 0))
if node.module:
self.write(node.module)
self.write(" import ")