mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-92986: Fix ast.unparse when ImportFrom.level is None (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
(GH-57645, GH-92987)
(cherry picked from commit 200c9a8da0)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
e13f49a0bc
commit
6cc31af657
3 changed files with 8 additions and 1 deletions
|
|
@ -341,6 +341,12 @@ def test_invalid_fstring_backslash(self):
|
|||
def test_invalid_yield_from(self):
|
||||
self.check_invalid(ast.YieldFrom(value=None))
|
||||
|
||||
def test_import_from_level_none(self):
|
||||
tree = ast.ImportFrom(module='mod', names=[ast.alias(name='x')])
|
||||
self.assertEqual(ast.unparse(tree), "from mod import x")
|
||||
tree = ast.ImportFrom(module='mod', names=[ast.alias(name='x')], level=None)
|
||||
self.assertEqual(ast.unparse(tree), "from mod import x")
|
||||
|
||||
def test_docstrings(self):
|
||||
docstrings = (
|
||||
'this ends with double quote"',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue