Commit df89ba0f authored by Stefan Behnel's avatar Stefan Behnel

Prevent config lookup of "C line in traceback" option from clearing the live...

Prevent config lookup of "C line in traceback" option from clearing the live exception and calling setattr() with a live exception set.
Closes #1907.
parent 53a3e9a2
...@@ -82,6 +82,8 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject ...@@ -82,6 +82,8 @@ static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
#endif #endif
...@@ -555,17 +557,22 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, ...@@ -555,17 +557,22 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
/////////////// CLineInTraceback.proto /////////////// /////////////// CLineInTraceback.proto ///////////////
static int __Pyx_CLineForTraceback(int c_line); #ifdef CYTHON_CLINE_IN_TRACEBACK /* 0 or 1 to disable/enable C line display in tracebacks at C compile time */
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);/*proto*/
#endif
/////////////// CLineInTraceback /////////////// /////////////// CLineInTraceback ///////////////
//@requires: ObjectHandling.c::PyObjectGetAttrStr //@requires: ObjectHandling.c::PyObjectGetAttrStr
//@requires: PyErrFetchRestore
//@substitute: naming //@substitute: naming
static int __Pyx_CLineForTraceback(int c_line) { #ifndef CYTHON_CLINE_IN_TRACEBACK
#ifdef CYTHON_CLINE_IN_TRACEBACK /* 0 or 1 to disable/enable C line display in tracebacks at C compile time */ static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
return ((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0;
#else
PyObject *use_cline; PyObject *use_cline;
PyObject *ptype, *pvalue, *ptraceback;
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON
PyObject **cython_runtime_dict = _PyObject_GetDictPtr(${cython_runtime_cname}); PyObject **cython_runtime_dict = _PyObject_GetDictPtr(${cython_runtime_cname});
...@@ -574,17 +581,14 @@ static int __Pyx_CLineForTraceback(int c_line) { ...@@ -574,17 +581,14 @@ static int __Pyx_CLineForTraceback(int c_line) {
} else } else
#endif #endif
{ {
PyObject *ptype, *pvalue, *ptraceback; PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"));
PyObject *use_cline_obj;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
use_cline_obj = __Pyx_PyObject_GetAttrStr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"));
if (use_cline_obj) { if (use_cline_obj) {
use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
Py_DECREF(use_cline_obj); Py_DECREF(use_cline_obj);
} else { } else {
PyErr_Clear();
use_cline = NULL; use_cline = NULL;
} }
PyErr_Restore(ptype, pvalue, ptraceback);
} }
if (!use_cline) { if (!use_cline) {
c_line = 0; c_line = 0;
...@@ -593,9 +597,10 @@ static int __Pyx_CLineForTraceback(int c_line) { ...@@ -593,9 +597,10 @@ static int __Pyx_CLineForTraceback(int c_line) {
else if (PyObject_Not(use_cline) != 0) { else if (PyObject_Not(use_cline) != 0) {
c_line = 0; c_line = 0;
} }
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
return c_line; return c_line;
#endif
} }
#endif
/////////////// AddTraceback.proto /////////////// /////////////// AddTraceback.proto ///////////////
...@@ -669,9 +674,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, ...@@ -669,9 +674,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename) { int py_line, const char *filename) {
PyCodeObject *py_code = 0; PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0; PyFrameObject *py_frame = 0;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
if (c_line) { if (c_line) {
c_line = __Pyx_CLineForTraceback(c_line); c_line = __Pyx_CLineForTraceback(tstate, c_line);
} }
// Negate to avoid collisions between py and c lines. // Negate to avoid collisions between py and c lines.
...@@ -683,7 +689,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, ...@@ -683,7 +689,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
$global_code_object_cache_insert(c_line ? -c_line : py_line, py_code); $global_code_object_cache_insert(c_line ? -c_line : py_line, py_code);
} }
py_frame = PyFrame_New( py_frame = PyFrame_New(
__Pyx_PyThreadState_Current, /*PyThreadState *tstate,*/ tstate, /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/ py_code, /*PyCodeObject *code,*/
$moddict_cname, /*PyObject *globals,*/ $moddict_cname, /*PyObject *globals,*/
0 /*PyObject *locals*/ 0 /*PyObject *locals*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment