Provide Module(..., type_ignores) for Python 3.8

This commit is contained in:
Kodi Arfer 2019-04-08 15:38:03 -04:00
parent 0c7ada1e63
commit 8df0a41d7d
4 changed files with 9 additions and 6 deletions

View File

@ -11,6 +11,7 @@ import sys, keyword, textwrap
PY3 = sys.version_info[0] >= 3 PY3 = sys.version_info[0] >= 3
PY36 = sys.version_info >= (3, 6) PY36 = sys.version_info >= (3, 6)
PY37 = sys.version_info >= (3, 7) PY37 = sys.version_info >= (3, 7)
PY38 = sys.version_info >= (3, 8)
# The value of UCS4 indicates whether Unicode strings are stored as UCS-4. # The value of UCS4 indicates whether Unicode strings are stored as UCS-4.
# It is always true on Pythons >= 3.3, which use USC-4 on all systems. # It is always true on Pythons >= 3.3, which use USC-4 on all systems.

View File

@ -270,8 +270,9 @@ class HyREPL(code.InteractiveConsole, object):
try: try:
# Mush the two AST chunks into a single module for # Mush the two AST chunks into a single module for
# conversion into Python. # conversion into Python.
new_ast = ast.Module(exec_ast.body + new_ast = ast.Module(
[ast.Expr(eval_ast.body)]) exec_ast.body + [ast.Expr(eval_ast.body)],
type_ignores=[])
print(astor.to_source(new_ast)) print(astor.to_source(new_ast))
except Exception: except Exception:
msg = 'Exception in AST callback:\n{}\n'.format( msg = 'Exception in AST callback:\n{}\n'.format(

View File

@ -2131,7 +2131,7 @@ def hy_compile(tree, module, root=ast.Module, get_expr=False,
key=lambda a: not (isinstance(a, ast.ImportFrom) and key=lambda a: not (isinstance(a, ast.ImportFrom) and
a.module == '__future__')) a.module == '__future__'))
ret = root(body=body) ret = root(body=body, type_ignores=[])
if get_expr: if get_expr:
expr = ast.Expression(body=expr) expr = ast.Expression(body=expr)

View File

@ -11,7 +11,7 @@
pytest) pytest)
(import sys) (import sys)
(import [hy._compat [PY3 PY37]]) (import [hy._compat [PY3 PY37 PY38]])
(defn test-sys-argv [] (defn test-sys-argv []
"NATIVE: test sys.argv" "NATIVE: test sys.argv"
@ -1550,10 +1550,11 @@ cee\"} dee" "ey bee\ncee dee"))
(defn test-disassemble [] (defn test-disassemble []
"NATIVE: Test the disassemble function" "NATIVE: Test the disassemble function"
(assert (= (disassemble '(do (leaky) (leaky) (macros))) (cond (assert (= (disassemble '(do (leaky) (leaky) (macros))) (cond
[PY3 "Module( [PY3 (.format "Module(
body=[Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[])), body=[Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[])),
Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[])), Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[])),
Expr(value=Call(func=Name(id='macros'), args=[], keywords=[]))])"] Expr(value=Call(func=Name(id='macros'), args=[], keywords=[]))]{})"
(if PY38 ",\n type_ignores=[]" ""))]
[True "Module( [True "Module(
body=[ body=[
Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[], starargs=None, kwargs=None)), Expr(value=Call(func=Name(id='leaky'), args=[], keywords=[], starargs=None, kwargs=None)),