Skip to content

Commit

Permalink
Python 2-3 ready now
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed Mar 22, 2020
1 parent 7d4d311 commit b555902
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions makefun/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,17 @@ def foo(a, b):
evaldict, _ = extract_module_and_evaldict(frame)

# compile all references first
if target.func_closure is not None:
for name, value in zip(target.func_code.co_freevars, (c.cell_contents for c in target.func_closure)):
try:
# python 3
func_closure = target.__closure__
func_code = target.__code__
except AttributeError:
# python 2
func_closure = target.func_closure
func_code = target.func_code

if func_closure is not None:
for name, value in zip(func_code.co_freevars, (c.cell_contents for c in func_closure)):
try:
evaldict[name] = compile_fun(value)
except UnsupportedForCompilation:
Expand Down

0 comments on commit b555902

Please sign in to comment.