Skip to content

Commit b555902

Browse files
author
Sylvain MARIE
committed
Python 2-3 ready now
1 parent 7d4d311 commit b555902

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

makefun/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,17 @@ def foo(a, b):
10041004
evaldict, _ = extract_module_and_evaldict(frame)
10051005

10061006
# compile all references first
1007-
if target.func_closure is not None:
1008-
for name, value in zip(target.func_code.co_freevars, (c.cell_contents for c in target.func_closure)):
1007+
try:
1008+
# python 3
1009+
func_closure = target.__closure__
1010+
func_code = target.__code__
1011+
except AttributeError:
1012+
# python 2
1013+
func_closure = target.func_closure
1014+
func_code = target.func_code
1015+
1016+
if func_closure is not None:
1017+
for name, value in zip(func_code.co_freevars, (c.cell_contents for c in func_closure)):
10091018
try:
10101019
evaldict[name] = compile_fun(value)
10111020
except UnsupportedForCompilation:

0 commit comments

Comments
 (0)