Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
9eee898c
Commit
9eee898c
authored
Jan 17, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch for ticket #646 by klepa: provide dedicated switches for 'c_line_in_traceback' option
parent
38a051cb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
21 deletions
+32
-21
Cython/Compiler/CmdLine.py
Cython/Compiler/CmdLine.py
+2
-0
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+20
-17
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+1
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+1
-1
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+0
-3
Cython/Distutils/build_ext.py
Cython/Distutils/build_ext.py
+4
-0
Cython/Distutils/extension.py
Cython/Distutils/extension.py
+4
-0
No files found.
Cython/Compiler/CmdLine.py
View file @
9eee898c
...
...
@@ -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
...
...
Cython/Compiler/Code.py
View file @
9eee898c
...
...
@@ -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
=
""
...
...
Cython/Compiler/Main.py
View file @
9eee898c
...
...
@@ -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
,
)
Cython/Compiler/ModuleNode.py
View file @
9eee898c
...
...
@@ -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'
]
...
...
Cython/Compiler/Options.py
View file @
9eee898c
...
...
@@ -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.
...
...
Cython/Distutils/build_ext.py
View file @
9eee898c
...
...
@@ -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
)
...
...
Cython/Distutils/extension.py
View file @
9eee898c
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment