Skip to content

Commit

Permalink
Merge pull request #4222 from lanzagar/featconst-py38
Browse files Browse the repository at this point in the history
[FIX] Feature Constructor: Compatibility with Python 3.8
  • Loading branch information
janezd authored Nov 29, 2019
2 parents 1970245 + 3acd879 commit 4127f20
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Orange/widgets/data/owfeatureconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,9 @@ def freevars(exp, env):
elif etype == ast.Starred:
# a 'starred' call parameter (e.g. a and b in `f(x, *a, *b)`
return freevars(exp.value, env)
elif etype in [ast.Num, ast.Str, ast.Ellipsis, ast.Bytes]:
elif etype in [ast.Num, ast.Str, ast.Ellipsis, ast.Bytes, ast.NameConstant]:
return []
elif etype == ast.NameConstant:
elif etype == ast.Constant:
return []
elif etype == ast.Attribute:
return freevars(exp.value, env)
Expand Down Expand Up @@ -836,9 +836,9 @@ def validate_exp(exp):
elif etype == ast.Starred:
assert isinstance(exp.ctx, ast.Load)
return validate_exp(exp.value)
elif etype in [ast.Num, ast.Str, ast.Bytes, ast.Ellipsis]:
elif etype in [ast.Num, ast.Str, ast.Bytes, ast.Ellipsis, ast.NameConstant]:
return True
elif etype == ast.NameConstant:
elif etype == ast.Constant:
return True
elif etype == ast.Attribute:
return True
Expand Down Expand Up @@ -947,6 +947,7 @@ def make_lambda(expression, args, env=None):
# lambda *{args}* : EXPRESSION
lambda_ = ast.Lambda(
args=ast.arguments(
posonlyargs=[],
args=[ast.arg(arg=arg, annotation=None) for arg in args],
varargs=None,
varargannotation=None,
Expand All @@ -961,6 +962,7 @@ def make_lambda(expression, args, env=None):
# lambda **{env}** : lambda *{args}*: EXPRESSION
outer = ast.Lambda(
args=ast.arguments(
posonlyargs=[],
args=[ast.arg(arg=name, annotation=None) for name in (env or {})],
varargs=None,
varargannotation=None,
Expand Down

0 comments on commit 4127f20

Please sign in to comment.