From: Stefan Behnel Date: Wed, 29 Apr 2009 17:48:49 +0000 (+0200) Subject: more closure tests X-Git-Tag: 0.13.beta0~2^2~153 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b6877b77875e3cd3a315a72f9837cd36ed6f8c6e;p=cython.git more closure tests --- diff --git a/tests/run/closures_T82.pyx b/tests/run/closures_T82.pyx index a78daf7c..45f08785 100644 --- a/tests/run/closures_T82.pyx +++ b/tests/run/closures_T82.pyx @@ -35,6 +35,10 @@ __doc__ = u""" #>>> py_twofuncs(3)(5) == cy_twofuncs(3)(5) #True +>>> inner_funcs = more_inner_funcs(1)(2,4,8) +# this currently segfaults: +#>>> inner_funcs[0](16), inner_funcs[1](32), inner_funcs[2](64) + """ def add_n(int n): @@ -86,9 +90,28 @@ def reassign_int_int(int x): def cy_twofuncs(x): - # pretty ugly segfault + # pretty ugly segfault in PyEval_EvalFrameEx() *after* calling cy_twofuncs() ! def f(a): return g(x) + a def g(b): return x + b return f + + +def more_inner_funcs(x): + # pretty ugly segfault + def f(a): # this lacks a GIVEREF() + def g(b): + return a+b+x + return g + def g(b): # this lacks a GIVEREF() + def f(a): + return a+b+x + return f + def h(b): # this lacks a GIVEREF() + def f(a): + return a+b+x + return f + def resolve(a_f, b_g, b_h): + return f(a_f), g(b_g), h(b_h) + return resolve