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
Gwenaël Samain
cython
Commits
4a7bea78
Commit
4a7bea78
authored
Aug 21, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backed out changeset a4bd0ff1da10
parent
dd3705db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
37 deletions
+20
-37
Cython/Compiler/Errors.py
Cython/Compiler/Errors.py
+2
-8
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+17
-28
tests/errors/e_switch.pyx
tests/errors/e_switch.pyx
+1
-1
No files found.
Cython/Compiler/Errors.py
View file @
4a7bea78
...
@@ -64,15 +64,10 @@ class InternalError(Exception):
...
@@ -64,15 +64,10 @@ class InternalError(Exception):
Exception
.
__init__
(
self
,
"Internal compiler error: %s"
Exception
.
__init__
(
self
,
"Internal compiler error: %s"
%
message
)
%
message
)
class
AbortCompilationError
(
Exception
):
"""
Raised in order to abort compilation.
"""
listing_file
=
None
listing_file
=
None
num_errors
=
0
num_errors
=
0
echo_file
=
None
echo_file
=
None
last_error
=
None
def
open_listing_file
(
path
,
echo_to_stderr
=
1
):
def
open_listing_file
(
path
,
echo_to_stderr
=
1
):
# Begin a new error listing. If path is None, no file
# Begin a new error listing. If path is None, no file
...
@@ -95,7 +90,7 @@ def close_listing_file():
...
@@ -95,7 +90,7 @@ def close_listing_file():
listing_file
=
None
listing_file
=
None
def
report_error
(
err
):
def
report_error
(
err
):
global
num_errors
,
last_error
global
num_errors
# See Main.py for why dual reporting occurs. Quick fix for now.
# See Main.py for why dual reporting occurs. Quick fix for now.
if
err
.
reported
:
return
if
err
.
reported
:
return
err
.
reported
=
True
err
.
reported
=
True
...
@@ -105,7 +100,6 @@ def report_error(err):
...
@@ -105,7 +100,6 @@ def report_error(err):
if
echo_file
:
if
echo_file
:
echo_file
.
write
(
line
)
echo_file
.
write
(
line
)
num_errors
=
num_errors
+
1
num_errors
=
num_errors
+
1
last_error
=
err
def
error
(
position
,
message
):
def
error
(
position
,
message
):
#print "Errors.error:", repr(position), repr(message) ###
#print "Errors.error:", repr(position), repr(message) ###
...
...
Cython/Compiler/Main.py
View file @
4a7bea78
...
@@ -84,11 +84,6 @@ class Context:
...
@@ -84,11 +84,6 @@ class Context:
from
Buffer
import
IntroduceBufferAuxiliaryVars
from
Buffer
import
IntroduceBufferAuxiliaryVars
from
ModuleNode
import
check_c_classes
from
ModuleNode
import
check_c_classes
def
abort_if_errors
(
t
):
if
Errors
.
num_errors
>
0
:
raise
Errors
.
AbortCompilationError
()
return
t
if
pxd
:
if
pxd
:
_check_c_classes
=
None
_check_c_classes
=
None
_specific_post_parse
=
PxdPostParse
(
self
)
_specific_post_parse
=
PxdPostParse
(
self
)
...
@@ -172,16 +167,10 @@ class Context:
...
@@ -172,16 +167,10 @@ class Context:
for
phase
in
pipeline
:
for
phase
in
pipeline
:
if
phase
is
not
None
:
if
phase
is
not
None
:
data
=
phase
(
data
)
data
=
phase
(
data
)
print
Errors
.
num_errors
except
CompileError
,
err
:
except
CompileError
,
err
:
print
"hello"
,
err
# err is set
Errors
.
report_error
(
err
)
Errors
.
report_error
(
err
)
raise
err
return
(
err
,
data
)
except
Errors
.
AbortCompilationError
:
print
"abort"
,
Errors
.
num_errors
pass
print
"normal"
return
data
def
find_module
(
self
,
module_name
,
def
find_module
(
self
,
module_name
,
relative_to
=
None
,
pos
=
None
,
need_pxd
=
1
):
relative_to
=
None
,
pos
=
None
,
need_pxd
=
1
):
...
@@ -238,7 +227,10 @@ class Context:
...
@@ -238,7 +227,10 @@ class Context:
if
debug_find_module
:
if
debug_find_module
:
print
(
"Context.find_module: Parsing %s"
%
pxd_pathname
)
print
(
"Context.find_module: Parsing %s"
%
pxd_pathname
)
source_desc
=
FileSourceDescriptor
(
pxd_pathname
)
source_desc
=
FileSourceDescriptor
(
pxd_pathname
)
pxd_codenodes
,
pxd_scope
=
self
.
process_pxd
(
source_desc
,
scope
,
module_name
)
err
,
result
=
self
.
process_pxd
(
source_desc
,
scope
,
module_name
)
if
err
:
raise
err
(
pxd_codenodes
,
pxd_scope
)
=
result
self
.
pxds
[
module_name
]
=
(
pxd_codenodes
,
pxd_scope
)
self
.
pxds
[
module_name
]
=
(
pxd_codenodes
,
pxd_scope
)
except
CompileError
:
except
CompileError
:
pass
pass
...
@@ -407,7 +399,7 @@ class Context:
...
@@ -407,7 +399,7 @@ class Context:
except
UnicodeDecodeError
,
msg
:
except
UnicodeDecodeError
,
msg
:
error
((
source_desc
,
0
,
0
),
"Decoding error, missing or incorrect coding=<encoding-name> at top of source (%s)"
%
msg
)
error
((
source_desc
,
0
,
0
),
"Decoding error, missing or incorrect coding=<encoding-name> at top of source (%s)"
%
msg
)
if
Errors
.
num_errors
>
0
:
if
Errors
.
num_errors
>
0
:
raise
Errors
.
AbortCompilationError
()
raise
CompileError
return
tree
return
tree
def
extract_module_name
(
self
,
path
,
options
):
def
extract_module_name
(
self
,
path
,
options
):
...
@@ -437,13 +429,15 @@ class Context:
...
@@ -437,13 +429,15 @@ class Context:
else
:
else
:
Errors
.
open_listing_file
(
None
)
Errors
.
open_listing_file
(
None
)
def
teardown_errors
(
self
,
options
,
result
):
def
teardown_errors
(
self
,
err
,
options
,
result
):
source_desc
=
result
.
compilation_source
.
source_desc
source_desc
=
result
.
compilation_source
.
source_desc
if
not
isinstance
(
source_desc
,
FileSourceDescriptor
):
if
not
isinstance
(
source_desc
,
FileSourceDescriptor
):
raise
RuntimeError
(
"Only file sources for code supported"
)
raise
RuntimeError
(
"Only file sources for code supported"
)
Errors
.
close_listing_file
()
Errors
.
close_listing_file
()
result
.
num_errors
=
Errors
.
num_errors
result
.
num_errors
=
Errors
.
num_errors
if
result
.
num_errors
>
0
and
result
.
c_file
:
if
result
.
num_errors
>
0
:
err
=
True
if
err
and
result
.
c_file
:
try
:
try
:
Utils
.
castrate_file
(
result
.
c_file
,
os
.
stat
(
source_desc
.
filename
))
Utils
.
castrate_file
(
result
.
c_file
,
os
.
stat
(
source_desc
.
filename
))
except
EnvironmentError
:
except
EnvironmentError
:
...
@@ -504,13 +498,8 @@ def run_pipeline(source, options, full_module_name = None):
...
@@ -504,13 +498,8 @@ def run_pipeline(source, options, full_module_name = None):
pipeline
=
context
.
create_pyx_pipeline
(
options
,
result
)
pipeline
=
context
.
create_pyx_pipeline
(
options
,
result
)
context
.
setup_errors
(
options
)
context
.
setup_errors
(
options
)
try
:
err
,
enddata
=
context
.
run_pipeline
(
pipeline
,
source
)
enddata
=
context
.
run_pipeline
(
pipeline
,
source
)
context
.
teardown_errors
(
err
,
options
,
result
)
except
Errors
.
CompileError
:
pass
except
Errors
.
AbortCompilationError
:
pass
context
.
teardown_errors
(
options
,
result
)
return
result
return
result
#------------------------------------------------------------------------
#------------------------------------------------------------------------
...
...
tests/errors/e_switch.pyx
View file @
4a7bea78
...
@@ -8,5 +8,5 @@ elif x == 4:
...
@@ -8,5 +8,5 @@ elif x == 4:
print
34
print
34
_ERRORS
=
"""
_ERRORS
=
"""
3:19
: undeclared name not builtin: NONEXISTING
4:23
: undeclared name not builtin: NONEXISTING
"""
"""
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