From: Mark Florisson Date: Wed, 8 Dec 2010 00:18:13 +0000 (+0100) Subject: Fetch and restore error for Cython locals dict building X-Git-Tag: 0.14.beta0~1^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=01fb1ac980be6a1fdeaebc5e7701eb4234788b28;p=cython.git Fetch and restore error for Cython locals dict building --- diff --git a/Cython/Debugger/libcython.py b/Cython/Debugger/libcython.py index 8c49bdd8..54d09b3f 100644 --- a/Cython/Debugger/libcython.py +++ b/Cython/Debugger/libcython.py @@ -1200,19 +1200,21 @@ class CyExec(CythonCommand, libpython.PyExec): expr, input_type = self.readcode(expr) executor = libpython.PythonCodeExecutor() - # get the dict of Cython globals and construct a dict in the inferior - # with Cython locals - global_dict = gdb.parse_and_eval( - '(PyObject *) PyModule_GetDict(__pyx_m)') - local_dict = gdb.parse_and_eval('(PyObject *) PyDict_New()') - - cython_function = self.get_cython_function() - - try: - self._fill_locals_dict(executor, libpython.pointervalue(local_dict)) - executor.evalcode(expr, input_type, global_dict, local_dict) - finally: - executor.decref(libpython.pointervalue(local_dict)) + with libpython.FetchAndRestoreError(): + # get the dict of Cython globals and construct a dict in the + # inferior with Cython locals + global_dict = gdb.parse_and_eval( + '(PyObject *) PyModule_GetDict(__pyx_m)') + local_dict = gdb.parse_and_eval('(PyObject *) PyDict_New()') + + cython_function = self.get_cython_function() + + try: + self._fill_locals_dict(executor, + libpython.pointervalue(local_dict)) + executor.evalcode(expr, input_type, global_dict, local_dict) + finally: + executor.decref(libpython.pointervalue(local_dict)) # Functions