Commit 77fd4991 authored by Stefan Behnel's avatar Stefan Behnel

minor refactoring of AddTraceback() function

parent 2c2c0aaf
...@@ -8647,13 +8647,12 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s, ...@@ -8647,13 +8647,12 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s,
#include "frameobject.h" #include "frameobject.h"
#include "traceback.h" #include "traceback.h"
static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s, static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
int %(LINENO)s, const char *%(FILENAME)s) { const char *funcname, int %(CLINENO)s,
int %(LINENO)s, const char *%(FILENAME)s) {
PyCodeObject *py_code = 0;
PyObject *py_srcfile = 0; PyObject *py_srcfile = 0;
PyObject *py_funcname = 0; PyObject *py_funcname = 0;
PyObject *py_globals = 0;
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
py_srcfile = PyString_FromString(%(FILENAME)s); py_srcfile = PyString_FromString(%(FILENAME)s);
...@@ -8676,8 +8675,6 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s, ...@@ -8676,8 +8675,6 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s,
#endif #endif
} }
if (!py_funcname) goto bad; if (!py_funcname) goto bad;
py_globals = PyModule_GetDict(%(GLOBALS)s);
if (!py_globals) goto bad;
py_code = __Pyx_PyCode_New( py_code = __Pyx_PyCode_New(
0, /*int argcount,*/ 0, /*int argcount,*/
0, /*int kwonlyargcount,*/ 0, /*int kwonlyargcount,*/
...@@ -8695,7 +8692,26 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s, ...@@ -8695,7 +8692,26 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s,
%(LINENO)s, /*int firstlineno,*/ %(LINENO)s, /*int firstlineno,*/
%(EMPTY_BYTES)s /*PyObject *lnotab*/ %(EMPTY_BYTES)s /*PyObject *lnotab*/
); );
Py_DECREF(py_srcfile);
Py_DECREF(py_funcname);
return py_code;
bad:
Py_XDECREF(py_srcfile);
Py_XDECREF(py_funcname);
return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s,
int %(LINENO)s, const char *%(FILENAME)s) {
PyCodeObject *py_code = 0;
PyObject *py_globals = 0;
PyFrameObject *py_frame = 0;
py_code = __Pyx_CreateCodeObjectForTraceback(
funcname, %(CLINENO)s, %(LINENO)s, %(FILENAME)s);
if (!py_code) goto bad; if (!py_code) goto bad;
py_globals = PyModule_GetDict(%(GLOBALS)s);
if (!py_globals) goto bad;
py_frame = PyFrame_New( py_frame = PyFrame_New(
PyThreadState_GET(), /*PyThreadState *tstate,*/ PyThreadState_GET(), /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/ py_code, /*PyCodeObject *code,*/
...@@ -8706,8 +8722,6 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s, ...@@ -8706,8 +8722,6 @@ static void __Pyx_AddTraceback(const char *funcname, int %(CLINENO)s,
py_frame->f_lineno = %(LINENO)s; py_frame->f_lineno = %(LINENO)s;
PyTraceBack_Here(py_frame); PyTraceBack_Here(py_frame);
bad: bad:
Py_XDECREF(py_srcfile);
Py_XDECREF(py_funcname);
Py_XDECREF(py_code); Py_XDECREF(py_code);
Py_XDECREF(py_frame); Py_XDECREF(py_frame);
} }
......
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