From f960367e486499759c81ece4121b9f4d8032b3a9 Mon Sep 17 00:00:00 2001 From: Mark Florisson Date: Mon, 8 Nov 2010 16:15:23 +0100 Subject: [PATCH] Fix converting a remote PyStringObject to a local string --- Cython/Debugger/libcython.py | 14 +++----------- Cython/Debugger/libpython.py | 4 +++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Cython/Debugger/libcython.py b/Cython/Debugger/libcython.py index 6208777c..dd3c9960 100644 --- a/Cython/Debugger/libcython.py +++ b/Cython/Debugger/libcython.py @@ -244,13 +244,8 @@ class CythonBase(object): if not pyframeobject: raise gdb.GdbError('Unable to read information on python frame') - try: - filename = pyframeobject.filename() - except RuntimeError: - filename = None - lineno = None - else: - lineno = pyframeobject.current_line_num() + filename = pyframeobject.filename() + lineno = pyframeobject.current_line_num() if pygments: lexer = pygments.lexers.PythonLexer(stripall=False) @@ -313,10 +308,7 @@ class CythonBase(object): # print this python function as a C function return self.print_stackframe(frame, index, is_c=True) - try: - func_name = str(pyframe.co_name) - except RuntimeError: - func_name = 'Unknown Function Name' + func_name = pyframe.co_name func_cname = 'PyEval_EvalFrameEx' func_args = [] elif self.is_cython_function(frame): diff --git a/Cython/Debugger/libpython.py b/Cython/Debugger/libpython.py index 6d212644..fb51cda4 100644 --- a/Cython/Debugger/libpython.py +++ b/Cython/Debugger/libpython.py @@ -975,7 +975,9 @@ class PyStringObjectPtr(PyObjectPtr): def __str__(self): field_ob_size = self.field('ob_size') field_ob_sval = self.field('ob_sval') - char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr) + char_ptr = field_ob_sval.address.cast( + gdb.lookup_type('char').pointer()) + return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) def proxyval(self, visited): -- 2.26.2