Give a whack at Python 3.4 support
This adds ast.arg for Python 3.4+, for FunctionDef args and other args (starargs, kwargs)
This commit is contained in:
parent
575388fc13
commit
26e2fb3606
@ -1699,12 +1699,32 @@ class HyASTCompiler(object):
|
|||||||
arglist = expression.pop(0)
|
arglist = expression.pop(0)
|
||||||
ret, args, defaults, stararg, kwargs = self._parse_lambda_list(arglist)
|
ret, args, defaults, stararg, kwargs = self._parse_lambda_list(arglist)
|
||||||
|
|
||||||
args = ast.arguments(
|
if sys.version_info[0] >= 3 and sys.version_info[1] >= 4:
|
||||||
args=[ast.Name(arg=ast_str(x), id=ast_str(x),
|
# Python 3.4+ requres that args are an ast.arg object, rather
|
||||||
|
# than an ast.Name or bare string.
|
||||||
|
args = [ast.arg(arg=ast_str(x),
|
||||||
|
annotation=None, ### Fix me!
|
||||||
|
lineno=x.start_line,
|
||||||
|
col_offset=x.start_column) for x in args]
|
||||||
|
|
||||||
|
# XXX: Beware. Beware. This wasn't put into the parse lambda
|
||||||
|
# list because it's really just an internal parsing thing.
|
||||||
|
|
||||||
|
if kwargs:
|
||||||
|
kwargs = ast.arg(arg=kwargs, annotation=None)
|
||||||
|
|
||||||
|
if stararg:
|
||||||
|
stararg = ast.arg(arg=stararg, annotation=None)
|
||||||
|
|
||||||
|
# Let's find a better home for these guys.
|
||||||
|
else:
|
||||||
|
args = [ast.Name(arg=ast_str(x), id=ast_str(x),
|
||||||
ctx=ast.Param(),
|
ctx=ast.Param(),
|
||||||
lineno=x.start_line,
|
lineno=x.start_line,
|
||||||
col_offset=x.start_column)
|
col_offset=x.start_column) for x in args]
|
||||||
for x in args],
|
|
||||||
|
args = ast.arguments(
|
||||||
|
args=args,
|
||||||
vararg=stararg,
|
vararg=stararg,
|
||||||
kwarg=kwargs,
|
kwarg=kwargs,
|
||||||
kwonlyargs=[],
|
kwonlyargs=[],
|
||||||
|
Loading…
Reference in New Issue
Block a user