def error_goto(self, pos):
lbl = self.error_label
self.use_label(lbl)
- return "{%s = %s[%s]; %s = %s; %s = %s; goto %s;}" % (
+ if Options.c_line_in_traceback:
+ cinfo = "%s = %s;" % (Naming.clineno_cname, Naming.line_c_macro)
+ else:
+ cinfo = ""
+ return "{%s = %s[%s]; %s = %s; %s goto %s;}" % (
Naming.filename_cname,
Naming.filetable_cname,
self.lookup_filename(pos[0]),
Naming.lineno_cname,
pos[1],
- Naming.clineno_cname,
- Naming.line_c_macro,
+ cinfo,
lbl)
def error_goto_if(self, cond, pos):
code.putln("return;")
code.put_label(code.error_label)
code.put_var_xdecrefs(env.temp_entries)
- code.putln('__Pyx_AddTraceback("%s",%s,%s);' % (env.qualified_name,Naming.cfilenm_cname,Naming.clineno_cname))
+ code.putln('__Pyx_AddTraceback("%s");' % env.qualified_name)
env.use_utility_code(Nodes.traceback_utility_code)
code.putln('}')
code.putln("return;")
code.put_label(code.error_label)
code.put_var_xdecrefs(env.temp_entries)
- code.putln('__Pyx_AddTraceback("%s",%s,%s);' % (env.qualified_name,Naming.cfilenm_cname,Naming.clineno_cname))
+ code.putln('__Pyx_AddTraceback("%s");' % env.qualified_name)
env.use_utility_code(Nodes.traceback_utility_code)
code.putln('}')
err_val = self.error_value()
exc_check = self.caller_will_check_exceptions()
if err_val is not None or exc_check:
- code.putln(
- '__Pyx_AddTraceback("%s",%s,%s);' %
- (self.entry.qualified_name,Naming.cfilenm_cname,Naming.clineno_cname))
+ code.putln('__Pyx_AddTraceback("%s");' % self.entry.qualified_name)
if err_val is not None:
code.putln(
"%s = %s;" % (
else:
code.putln(
"/*except:*/ {")
- code.putln(
- '__Pyx_AddTraceback("%s",%s,%s);' % (self.function_name, Naming.cfilenm_cname,Naming.clineno_cname))
+ code.putln('__Pyx_AddTraceback("%s");' % self.function_name)
# We always have to fetch the exception value even if
# there is no target, because this also normalises the
# exception and stores it in the thread state.
traceback_utility_code = [
"""
-static void __Pyx_AddTraceback(char *funcname, char* cfilename, unsigned int cfileline); /*proto*/
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
""","""
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
-static void __Pyx_AddTraceback(char *funcname, char* cfilename, unsigned int cfileline) {
+static void __Pyx_AddTraceback(char *funcname) {
PyObject *py_srcfile = 0;
PyObject *py_funcname = 0;
PyObject *py_globals = 0;
py_srcfile = PyString_FromString(%(FILENAME)s);
if (!py_srcfile) goto bad;
- py_funcname = PyString_FromFormat( "%%s, %%s, %%u", funcname, cfilename, cfileline);
+ if (%(CLINENO)s) {
+ py_funcname = PyString_FromFormat( "%%s (%%s:%%u)", funcname, %(CFILENAME)s, %(CLINENO)s);
+ }
+ else {
+ py_funcname = PyString_FromString(funcname);
+ }
if (!py_funcname) goto bad;
py_globals = PyModule_GetDict(%(GLOBALS)s);
if (!py_globals) goto bad;
""" % {
'FILENAME': Naming.filename_cname,
'LINENO': Naming.lineno_cname,
+ 'CFILENAME': Naming.cfilenm_cname,
+ 'CLINENO': Naming.clineno_cname,
'GLOBALS': Naming.module_cname,
'EMPTY_TUPLE' : Naming.empty_tuple,
}]