Author: Edd Barrett <vex...@gmail.com> Branch: improve-errors-again Changeset: r66412:79c2e7e9bdd8 Date: 2013-08-28 12:31 +0100 http://bitbucket.org/pypy/pypy/changeset/79c2e7e9bdd8/
Log: (Ronan, Edd) Move AnnotatorError to a place that makes more sense. diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py --- a/rpython/annotator/annrpython.py +++ b/rpython/annotator/annrpython.py @@ -5,7 +5,7 @@ from rpython.tool.ansi_print import ansi_log from rpython.tool.pairtype import pair from rpython.tool.error import (format_blocked_annotation_error, - AnnotatorError, gather_error, ErrorWrapper, source_lines) + gather_error, ErrorWrapper, source_lines) from rpython.flowspace.model import (Variable, Constant, FunctionGraph, c_last_exception, checkgraph) from rpython.translator import simplify, transform @@ -18,7 +18,6 @@ FAIL = object() - class RPythonAnnotator(object): """Block annotator for RPython. See description in doc/translation.txt.""" @@ -221,7 +220,7 @@ text = format_blocked_annotation_error(self, self.blocked_blocks) #raise SystemExit() - raise AnnotatorError(text) + raise annmodel.AnnotatorError(text) for graph in newgraphs: v = graph.getreturnvar() if v not in self.bindings: diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py --- a/rpython/annotator/binaryop.py +++ b/rpython/annotator/binaryop.py @@ -20,7 +20,7 @@ from rpython.annotator.bookkeeper import getbookkeeper from rpython.flowspace.model import Variable, Constant from rpython.rlib import rarithmetic -from rpython.tool.error import AnnotatorError +from rpython.annotator.model import AnnotatorError # convenience only! def immutablevalue(x): diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py --- a/rpython/annotator/model.py +++ b/rpython/annotator/model.py @@ -676,6 +676,10 @@ # ____________________________________________________________ + +class AnnotatorError(Exception): + pass + class UnionError(Exception): """Signals an suspicious attempt at taking the union of deeply incompatible SomeXxx instances.""" diff --git a/rpython/annotator/test/test_model.py b/rpython/annotator/test/test_model.py --- a/rpython/annotator/test/test_model.py +++ b/rpython/annotator/test/test_model.py @@ -2,6 +2,7 @@ from rpython.annotator.model import * from rpython.annotator.listdef import ListDef +from rpython.translator.translator import TranslationContext listdef1 = ListDef(None, SomeTuple([SomeInteger(nonneg=True), SomeString()])) @@ -174,6 +175,28 @@ assert f2.contains(f1) assert f1.contains(f2) +def compile_function(function, annotation=[]): + t = TranslationContext() + t.buildannotator().build_types(function, annotation) + +class AAA(object): + pass + +def test_blocked_inference1(): + def blocked_inference(): + return AAA().m() + + py.test.raises(AnnotatorError, compile_function, blocked_inference) + +def test_blocked_inference2(): + def blocked_inference(): + a = AAA() + b = a.x + return b + + py.test.raises(AnnotatorError, compile_function, blocked_inference) + + if __name__ == '__main__': for name, value in globals().items(): if name.startswith('test_'): diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py --- a/rpython/annotator/unaryop.py +++ b/rpython/annotator/unaryop.py @@ -14,7 +14,7 @@ from rpython.annotator.bookkeeper import getbookkeeper from rpython.annotator import builtin from rpython.annotator.binaryop import _clone ## XXX where to put this? -from rpython.tool.error import AnnotatorError +from rpython.annotator.model import AnnotatorError # convenience only! def immutablevalue(x): diff --git a/rpython/tool/error.py b/rpython/tool/error.py --- a/rpython/tool/error.py +++ b/rpython/tool/error.py @@ -68,9 +68,6 @@ lines = source_lines1(graph, *args, **kwds) return ['In %r:' % (graph,)] + lines -class AnnotatorError(Exception): - pass - class NoSuchAttrError(Exception): pass @@ -79,7 +76,7 @@ self.msg = msg def __repr__(self): - return '<%s>' % (self.msg,) + return '%s' % (self.msg,) def gather_error(annotator, graph, block, operindex): msg = [""] diff --git a/rpython/tool/test/test_error.py b/rpython/tool/test/test_error.py --- a/rpython/tool/test/test_error.py +++ b/rpython/tool/test/test_error.py @@ -3,33 +3,10 @@ """ from rpython.translator.translator import TranslationContext -from rpython.tool.error import AnnotatorError from rpython.annotator.model import UnionError import py - -def compile_function(function, annotation=[]): - t = TranslationContext() - t.buildannotator().build_types(function, annotation) - -class AAA(object): - pass - -def test_blocked_inference1(): - def blocked_inference(): - return AAA().m() - - py.test.raises(AnnotatorError, compile_function, blocked_inference) - -def test_blocked_inference2(): - def blocked_inference(): - a = AAA() - b = a.x - return b - - py.test.raises(AnnotatorError, compile_function, blocked_inference) - def test_someobject(): def someobject_degeneration(n): if n == 3: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit