From 6689e031f65579bde60bb55c7b676c9795ad88c5 Mon Sep 17 00:00:00 2001 From: Mark Florisson Date: Tue, 18 Jan 2011 20:55:55 +0100 Subject: [PATCH] Debugger: fix is_initialized to avoid segfaults with cy exec --- Cython/Debugger/libcython.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Cython/Debugger/libcython.py b/Cython/Debugger/libcython.py index 606fd512..0aa4bcfa 100644 --- a/Cython/Debugger/libcython.py +++ b/Cython/Debugger/libcython.py @@ -389,20 +389,19 @@ class CythonBase(object): value) def is_initialized(self, cython_func, local_name): - islocal = local_name in cython_func.locals - if islocal: - cyvar = cython_func.locals[local_name] - if '->' in cyvar.cname: - # Closed over free variable - if self.get_cython_lineno() >= cython_func.lineno + 1: - if cyvar.type == PythonObject: - return long(gdb.parse_and_eval(cyvar.cname)) - return True - return False - + cyvar = cython_func.locals[local_name] cur_lineno = self.get_cython_lineno() - return (local_name in cython_func.arguments or - (islocal and cur_lineno > cyvar.lineno)) + + if '->' in cyvar.cname: + # Closed over free variable + if cur_lineno > cython_func.lineno: + if cyvar.type == PythonObject: + return long(gdb.parse_and_eval(cyvar.cname)) + return True + return False + + return cur_lineno > cyvar.lineno + class SourceFileDescriptor(object): def __init__(self, filename, lexer, formatter=None): -- 2.26.2