We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7d4d311 commit b555902Copy full SHA for b555902
makefun/main.py
@@ -1004,8 +1004,17 @@ def foo(a, b):
1004
evaldict, _ = extract_module_and_evaldict(frame)
1005
1006
# 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)):
+ try:
+ # 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)):
1018
try:
1019
evaldict[name] = compile_fun(value)
1020
except UnsupportedForCompilation:
0 commit comments