Commit 26589357 authored by Robert Bradshaw's avatar Robert Bradshaw

Merge pull request #478 from eugulixes/__PYX_ERR

Hide some parts of stack trace in __PYX_ERR macro
parents eff599d2 b6d9e27e
...@@ -2145,8 +2145,9 @@ class CCodeWriter(object): ...@@ -2145,8 +2145,9 @@ class CCodeWriter(object):
def error_goto(self, pos): def error_goto(self, pos):
lbl = self.funcstate.error_label lbl = self.funcstate.error_label
self.funcstate.use_label(lbl) self.funcstate.use_label(lbl)
return "{%s goto %s;}" % ( return "__PYX_ERR(%s, %s, %s)" % (
self.set_error_info(pos), self.lookup_filename(pos[0]),
pos[1],
lbl) lbl)
def error_goto_if(self, cond, pos): def error_goto_if(self, cond, pos):
......
...@@ -335,7 +335,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -335,7 +335,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
globalstate.initialize_main_c_code() globalstate.initialize_main_c_code()
h_code = globalstate['h_code'] h_code = globalstate['h_code']
self.generate_module_preamble(env, modules, result.embedded_metadata, h_code) self.generate_module_preamble(env, options, modules, result.embedded_metadata, h_code)
globalstate.module_pos = self.pos globalstate.module_pos = self.pos
globalstate.directives = self.directives globalstate.directives = self.directives
...@@ -590,7 +590,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -590,7 +590,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def _put_setup_code(self, code, name): def _put_setup_code(self, code, name):
code.put(UtilityCode.load_as_string(name, "ModuleSetupCode.c")[1]) code.put(UtilityCode.load_as_string(name, "ModuleSetupCode.c")[1])
def generate_module_preamble(self, env, cimported_modules, metadata, code): def generate_module_preamble(self, env, options, cimported_modules, metadata, code):
code.put_generated_by() code.put_generated_by()
if metadata: if metadata:
code.putln("/* BEGIN: Cython Metadata") code.putln("/* BEGIN: Cython Metadata")
...@@ -618,6 +618,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -618,6 +618,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self._put_setup_code(code, "CInitCode") self._put_setup_code(code, "CInitCode")
self._put_setup_code(code, "MathInitCode") self._put_setup_code(code, "MathInitCode")
if options.c_line_in_traceback:
cinfo = "%s = %s; " % (Naming.clineno_cname, Naming.line_c_macro)
else:
cinfo = ""
code.put("""
#define __PYX_ERR(f_index, lineno, Ln_error) \\
{ \\
%s = %s[f_index]; %s = lineno; %sgoto Ln_error; \\
}
""" % (Naming.filename_cname, Naming.filetable_cname, Naming.lineno_cname,
cinfo))
code.put(""" code.put("""
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
......
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