coming from the same root share the same instances simultaneously.
"""
- # f file output file
- # buffer StringIOTree
-
- # level int indentation level
- # bol bool beginning of line?
- # marker string comment to emit before next line
- # funcstate FunctionState contains state local to a C function used for code
- # generation (labels and temps state etc.)
- # globalstate GlobalState contains state global for a C file (input file info,
- # utility code, declared constants etc.)
- # emit_linenums boolean whether or not to write #line pragmas
+ # f file output file
+ # buffer StringIOTree
+
+ # level int indentation level
+ # bol bool beginning of line?
+ # marker string comment to emit before next line
+ # funcstate FunctionState contains state local to a C function used for code
+ # generation (labels and temps state etc.)
+ # globalstate GlobalState contains state global for a C file (input file info,
+ # utility code, declared constants etc.)
+ # emit_linenums boolean whether or not to write #line pragmas
#
- # pyclass_stack list used during recursive code generation to pass information
- # about the current class one is in
+ # c_line_in_traceback boolean append the c file and line number to the traceback for exceptions
+ #
+ # pyclass_stack list used during recursive code generation to pass information
+ # about the current class one is in
globalstate = None
- def __init__(self, create_from=None, buffer=None, copy_formatting=False, emit_linenums=None):
+ def __init__(self, create_from=None, buffer=None, copy_formatting=False, emit_linenums=None, c_line_in_traceback=True):
if buffer is None: buffer = StringIOTree()
self.buffer = buffer
self.marker = None
self.emit_linenums = self.globalstate.emit_linenums
else:
self.emit_linenums = emit_linenums
+ self.c_line_in_traceback = c_line_in_traceback
def create_new(self, create_from, buffer, copy_formatting):
# polymorphic constructor -- very slightly more versatile
# than using __class__
- result = CCodeWriter(create_from, buffer, copy_formatting)
+ result = CCodeWriter(create_from, buffer, copy_formatting, c_line_in_traceback=self.c_line_in_traceback)
return result
def copyto(self, f):
Creates a new CCodeWriter connected to the same global state, which
can later be inserted using insert.
"""
- return CCodeWriter(create_from=self)
+ return CCodeWriter(create_from=self, c_line_in_traceback=self.c_line_in_traceback)
def insert(self, writer):
"""
return self.putln("if (%s < 0) %s" % (value, self.error_goto(pos)))
def set_error_info(self, pos):
- if Options.c_line_in_traceback:
+ if self.c_line_in_traceback:
cinfo = " %s = %s;" % (Naming.clineno_cname, Naming.line_c_macro)
else:
cinfo = ""
self.pyrex_c_in_temp = 0
self.pyrex_gen_pxi = 0
self.pyrex_gdb = False
+ self.no_c_in_traceback = 0
def finalize_options (self):
_build_ext.build_ext.finalize_options(self)
getattr(extension, 'pyrex_create_listing', 0)
line_directives = self.pyrex_line_directives or \
getattr(extension, 'pyrex_line_directives', 0)
+ no_c_in_traceback = self.no_c_in_traceback or \
+ getattr(extension, 'no_c_in_traceback', 0)
cplus = self.pyrex_cplus or getattr(extension, 'pyrex_cplus', 0) or \
(extension.language and extension.language.lower() == 'c++')
pyrex_gen_pxi = self.pyrex_gen_pxi or getattr(extension, 'pyrex_gen_pxi', 0)
output_file = target,
cplus = cplus,
emit_linenums = line_directives,
+ c_line_in_traceback = not no_c_in_traceback,
generate_pxi = pyrex_gen_pxi,
output_dir = output_dir,
gdb_debug = pyrex_gdb)
generate .pxi file for public declarations
pyrex_gdb : boolean
generate Cython debug information for this extension for cygdb
+ no_c_in_traceback : boolean
+ emit the c file and line number from the traceback for exceptions
"""
# When adding arguments to this constructor, be sure to update
pyrex_c_in_temp = 0,
pyrex_gen_pxi = 0,
pyrex_gdb = False,
+ no_c_in_traceback = False,
**kw):
_Extension.Extension.__init__(self, name, sources,
self.pyrex_c_in_temp = pyrex_c_in_temp
self.pyrex_gen_pxi = pyrex_gen_pxi
self.pyrex_gdb = pyrex_gdb
+ self.no_c_in_traceback = no_c_in_traceback
# class Extension