# serialize functions
self.tb.start('Functions')
+ # First, serialize functions normally...
self.visitchildren(node)
+
+ # ... then, serialize nested functions
for nested_funcdef in self.nested_funcdefs:
self.visit_FuncDefNode(nested_funcdef)
-
+
+ self.register_stepinto = True
+ self.serialize_modulenode_as_function(node)
+ self.register_stepinto = False
self.tb.end('Functions')
# 2.3 compatibility. Serialize global variables
gdb.execute('cy exec some_random_var = 14')
self.assertEqual('14', self.eval_command('some_random_var'))
+class TestClosure(DebugTestCase):
+
+ def test_cython_closure(self):
+ self.break_and_run('def inner():')
+
++ # Allow the Cython-generated code to initialize the scope variable
++ gdb.execute('cy step')
++
+ self.assertEqual(str(self.read_var('a')), '1')
+ print_result = gdb.execute('cy print a', to_string=True).strip()
+ self.assertEqual(print_result, 'a = 1')
+
+ def test_cython_closure_no_closing_variables(self):
+ self.break_and_run('def inner2():')
+ self.assertEqual(gdb.execute('cy locals', to_string=True), '')
+
_do_debug = os.environ.get('GDB_DEBUG')
if _do_debug: