Skip to content

Commit

Permalink
AST conversion supports Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
hunse committed Jun 6, 2016
1 parent 5f26441 commit 6de4f06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions nengo_ocl/ast_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ def to_ocl(self, wrap=False):
raise NotImplementedError(
"'%s' function is not supported" % (fn.__name__))

try:
argcount = converter.func_code.co_argcount
except AttributeError:
argcount = converter.__code__.co_argcount
argcount = converter.__code__.co_argcount
if argcount != len(args):
raise NotImplementedError(
"'%s' function is not supported for %d arguments"
Expand Down Expand Up @@ -845,7 +842,7 @@ def wrapper(x): # need a wrapper to copy variables
try:
globals_dict = fn.func_globals
closure_dict = (
dict(zip(fn.func_code.co_freevars,
dict(zip(fn.__code__.co_freevars,
[c.cell_contents for c in fn.func_closure]))
if fn.func_closure is not None else {})
except AttributeError:
Expand Down
4 changes: 2 additions & 2 deletions nengo_ocl/tests/test_ast_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_functions(Simulator, n_points=10):

dfuncs = ast_conversion.direct_funcs
ifuncs = ast_conversion.indirect_funcs
functions = dfuncs.keys() + ifuncs.keys()
functions = list(dfuncs.keys()) + list(ifuncs.keys())
functions = [f for f in functions if f not in ignore]
all_passed = True
for fn in functions:
Expand All @@ -257,7 +257,7 @@ def wrapper(x):
lambda_fn = ifuncs[fn]
while lambda_fn.__name__ != '<lambda>':
lambda_fn = ifuncs[lambda_fn]
dims = lambda_fn.func_code.co_argcount
dims = lambda_fn.__code__.co_argcount

if dims == 1:
def wrapper(x):
Expand Down

0 comments on commit 6de4f06

Please sign in to comment.