Commit 75c3536e authored by Robert Bradshaw's avatar Robert Bradshaw

Fix fatal errors + nice exception traceback interaction.

parent c6ecb09c
......@@ -61,7 +61,6 @@ class CompileWarning(PyrexWarning):
# self.message = message
Exception.__init__(self, format_position(position) + message)
class InternalError(Exception):
# If this is ever raised, there is a bug in the compiler.
......@@ -70,6 +69,12 @@ class InternalError(Exception):
Exception.__init__(self, u"Internal compiler error: %s"
% message)
class AbortError(Exception):
# Throw this to stop the compilation immediately.
def __init__(self, message):
self.message_only = message
Exception.__init__(self, u"Abort error: %s" % message)
class CompilerCrash(CompileError):
# raised when an unexpected exception occurs in a transform
......@@ -140,7 +145,7 @@ def report_error(err):
echo_file.write(line.encode('ASCII', 'replace'))
num_errors = num_errors + 1
if Options.fatal_errors:
raise InternalError, "abort"
raise AbortError, "fatal errors"
def error(position, message):
#print "Errors.error:", repr(position), repr(message) ###
......
......@@ -19,7 +19,7 @@ import Errors
import Parsing
import Version
from Scanning import PyrexScanner, FileSourceDescriptor
from Errors import PyrexError, CompileError, InternalError, error, warning
from Errors import PyrexError, CompileError, InternalError, AbortError, error, warning
from Symtab import BuiltinScope, ModuleScope
from Cython import Utils
from Cython.Utils import open_new_file, replace_suffix
......@@ -38,7 +38,7 @@ def dumptree(t):
def abort_on_errors(node):
# Stop the pipeline if there are any errors.
if Errors.num_errors != 0:
raise InternalError, "abort"
raise AbortError, "pipeline break"
return node
class CompilationData(object):
......@@ -218,23 +218,26 @@ class Context(object):
error = None
data = source
try:
for phase in pipeline:
if phase is not None:
if DebugFlags.debug_verbose_pipeline:
t = time()
print "Entering pipeline phase %r" % phase
data = phase(data)
if DebugFlags.debug_verbose_pipeline:
print " %.3f seconds" % (time() - t)
except CompileError, err:
# err is set
Errors.report_error(err)
error = err
try:
for phase in pipeline:
if phase is not None:
if DebugFlags.debug_verbose_pipeline:
t = time()
print "Entering pipeline phase %r" % phase
data = phase(data)
if DebugFlags.debug_verbose_pipeline:
print " %.3f seconds" % (time() - t)
except CompileError, err:
# err is set
Errors.report_error(err)
error = err
except InternalError, err:
# Only raise if there was not an earlier error
if Errors.num_errors == 0:
raise
error = err
except AbortError, err:
error = err
return (error, data)
def find_module(self, module_name,
......
......@@ -173,6 +173,8 @@ class TreeVisitor(object):
result = handler_method(child)
except Errors.CompileError:
raise
except Errors.AbortError:
raise
except Exception, e:
if DebugFlags.debug_no_exception_intercept:
raise
......
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