Merge pull request #1613 from Kodiologist/modname-mangle-bug
Fix a regression with mangling module names
This commit is contained in:
commit
aae1f8718c
@ -1122,11 +1122,10 @@ class HyASTCompiler(object):
|
||||
names = [ast.alias(name="*", asname=None)]
|
||||
elif assignments == "ALL":
|
||||
node = asty.Import
|
||||
prefix = ast_str(prefix, piecewise=True)
|
||||
names = [ast.alias(
|
||||
name=ast_module,
|
||||
asname=ast_str(prefix)
|
||||
if prefix and prefix != module
|
||||
else None)]
|
||||
asname=prefix if prefix != module else None)]
|
||||
else:
|
||||
node = asty.ImportFrom
|
||||
names = [
|
||||
|
@ -256,6 +256,14 @@ def test_ast_bad_yield():
|
||||
cant_compile("(yield 1 2)")
|
||||
|
||||
|
||||
def test_ast_import_mangle_dotted():
|
||||
"""Mangling a module name with a period shouldn't create a spurious
|
||||
`asname`."""
|
||||
code = can_compile("(import a-b.c)")
|
||||
assert code.body[0].names[0].name == "a_b.c"
|
||||
assert code.body[0].names[0].asname is None
|
||||
|
||||
|
||||
def test_ast_good_import_from():
|
||||
"Make sure AST can compile valid selective import"
|
||||
can_compile("(import [x [y]])")
|
||||
|
Loading…
Reference in New Issue
Block a user