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)]
|
names = [ast.alias(name="*", asname=None)]
|
||||||
elif assignments == "ALL":
|
elif assignments == "ALL":
|
||||||
node = asty.Import
|
node = asty.Import
|
||||||
|
prefix = ast_str(prefix, piecewise=True)
|
||||||
names = [ast.alias(
|
names = [ast.alias(
|
||||||
name=ast_module,
|
name=ast_module,
|
||||||
asname=ast_str(prefix)
|
asname=prefix if prefix != module else None)]
|
||||||
if prefix and prefix != module
|
|
||||||
else None)]
|
|
||||||
else:
|
else:
|
||||||
node = asty.ImportFrom
|
node = asty.ImportFrom
|
||||||
names = [
|
names = [
|
||||||
|
@ -256,6 +256,14 @@ def test_ast_bad_yield():
|
|||||||
cant_compile("(yield 1 2)")
|
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():
|
def test_ast_good_import_from():
|
||||||
"Make sure AST can compile valid selective import"
|
"Make sure AST can compile valid selective import"
|
||||||
can_compile("(import [x [y]])")
|
can_compile("(import [x [y]])")
|
||||||
|
Loading…
Reference in New Issue
Block a user