Commit 13a88f95 authored by Stefan Behnel's avatar Stefan Behnel

extract C-line handling from AddTraceback() into separate function to keep...

extract C-line handling from AddTraceback() into separate function to keep AddTraceback() available as a shared header file
parent f7f9ae4c
......@@ -529,6 +529,32 @@ static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
#endif
}
/////////////// CLineInTraceback.proto ///////////////
static int __Pyx_CLineForTraceback(int c_line);
/////////////// CLineInTraceback ///////////////
//@requires: ObjectHandling.c::PyObjectGetAttrStr
//@substitute: naming
static int __Pyx_CLineForTraceback(int c_line) {
PyObject *ptype, *pvalue, *ptraceback;
PyObject *use_cline;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
use_cline = __Pyx_PyObject_GetAttrStr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"));
if (!use_cline) {
c_line = 0;
PyObject_SetAttr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"), Py_False);
}
else if (PyObject_Not(use_cline) != 0) {
c_line = 0;
}
Py_XDECREF(use_cline);
PyErr_Restore(ptype, pvalue, ptraceback);
return c_line;
}
/////////////// AddTraceback.proto ///////////////
static void __Pyx_AddTraceback(const char *funcname, int c_line,
......@@ -536,7 +562,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
/////////////// AddTraceback ///////////////
//@requires: ModuleSetupCode.c::CodeObjectCache
//@requires: ObjectHandling.c::PyObjectGetAttrStr
//@requires: CLineInTraceback
//@substitute: naming
#include "compile.h"
......@@ -601,20 +627,9 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
PyObject *use_cline = 0;
PyObject *ptype, *pvalue, *ptraceback;
if (c_line) {
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
use_cline = __Pyx_PyObject_GetAttrStr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"));
if (use_cline == NULL) {
c_line = 0;
PyObject_SetAttr(${cython_runtime_cname}, PYIDENT("cline_in_traceback"), Py_False);
}
else if (PyObject_Not(use_cline) != 0) {
c_line = 0;
}
PyErr_Restore(ptype, pvalue, ptraceback);
c_line = __Pyx_CLineForTraceback(c_line);
}
// Negate to avoid collisions between py and c lines.
......@@ -637,5 +652,4 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
bad:
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
Py_XDECREF(use_cline);
}
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