summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <scoder@users.berlios.de>2011-01-17 17:11:55 +0100
committerStefan Behnel <scoder@users.berlios.de>2011-01-17 17:11:55 +0100
commit9eee898ce75c59765e367cdcff9db2b55ad4d73f (patch)
tree71792d3d91adbd847f12c323ac40c167bbdd53e2
parent38a051cb15bc728d4d17b716a1b67ae8d1d375d0 (diff)
downloadcython-9eee898ce75c59765e367cdcff9db2b55ad4d73f.tar.gz
patch for ticket #646 by klepa: provide dedicated switches for 'c_line_in_traceback' option
-rw-r--r--Cython/Compiler/CmdLine.py2
-rw-r--r--Cython/Compiler/Code.py37
-rw-r--r--Cython/Compiler/Main.py1
-rw-r--r--Cython/Compiler/ModuleNode.py2
-rw-r--r--Cython/Compiler/Options.py3
-rw-r--r--Cython/Distutils/build_ext.py4
-rw-r--r--Cython/Distutils/extension.py4
7 files changed, 32 insertions, 21 deletions
diff --git a/Cython/Compiler/CmdLine.py b/Cython/Compiler/CmdLine.py
index 4cc3a971d..7b0bc390f 100644
--- a/Cython/Compiler/CmdLine.py
+++ b/Cython/Compiler/CmdLine.py
@@ -116,6 +116,8 @@ def parse_command_line(args):
Options.convert_range = True
elif option == "--line-directives":
options.emit_linenums = True
+ elif option == "--no-c-in-traceback":
+ options.c_line_in_traceback = False
elif option == "--gdb":
options.gdb_debug = True
options.output_dir = os.curdir
diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py
index 47ca0e583..41221cf88 100644
--- a/Cython/Compiler/Code.py
+++ b/Cython/Compiler/Code.py
@@ -860,24 +860,26 @@ class CCodeWriter(object):
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
@@ -902,11 +904,12 @@ class CCodeWriter(object):
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):
@@ -935,7 +938,7 @@ class CCodeWriter(object):
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):
"""
@@ -1319,7 +1322,7 @@ class CCodeWriter(object):
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 = ""
diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py
index 539d2ef92..c20d7a7c5 100644
--- a/Cython/Compiler/Main.py
+++ b/Cython/Compiler/Main.py
@@ -837,6 +837,7 @@ default_options = dict(
evaluate_tree_assertions = False,
emit_linenums = False,
relative_path_in_code_position_comments = True,
+ c_line_in_traceback = True,
language_level = 2,
gdb_debug = False,
)
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
index ceb618822..7d90bc8ae 100644
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -258,7 +258,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
rootwriter = Annotate.AnnotationCCodeWriter()
else:
emit_linenums = options.emit_linenums
- rootwriter = Code.CCodeWriter(emit_linenums=emit_linenums)
+ rootwriter = Code.CCodeWriter(emit_linenums=emit_linenums, c_line_in_traceback=options.c_line_in_traceback)
globalstate = Code.GlobalState(rootwriter, emit_linenums)
globalstate.initialize_main_c_code()
h_code = globalstate['h_code']
diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py
index 5ed89b856..4068db7d1 100644
--- a/Cython/Compiler/Options.py
+++ b/Cython/Compiler/Options.py
@@ -43,9 +43,6 @@ lookup_module_cpdef = 0
# WARNING: This is a work in progress, may currently segfault.
init_local_none = 1
-# Append the c file and line number to the traceback for exceptions.
-c_line_in_traceback = 1
-
# Whether or not to embed the Python interpreter, for use in making a
# standalone executable. This will provide a main() method which simply
# executes the body of this module.
diff --git a/Cython/Distutils/build_ext.py b/Cython/Distutils/build_ext.py
index 94673633a..4b07fbdfa 100644
--- a/Cython/Distutils/build_ext.py
+++ b/Cython/Distutils/build_ext.py
@@ -110,6 +110,7 @@ class build_ext(_build_ext.build_ext):
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)
@@ -185,6 +186,8 @@ class build_ext(_build_ext.build_ext):
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)
@@ -274,6 +277,7 @@ class build_ext(_build_ext.build_ext):
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)
diff --git a/Cython/Distutils/extension.py b/Cython/Distutils/extension.py
index 05528917e..52beb8ff2 100644
--- a/Cython/Distutils/extension.py
+++ b/Cython/Distutils/extension.py
@@ -33,6 +33,8 @@ class Extension(_Extension.Extension):
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
@@ -59,6 +61,7 @@ class Extension(_Extension.Extension):
pyrex_c_in_temp = 0,
pyrex_gen_pxi = 0,
pyrex_gdb = False,
+ no_c_in_traceback = False,
**kw):
_Extension.Extension.__init__(self, name, sources,
@@ -85,6 +88,7 @@ class Extension(_Extension.Extension):
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