Author: Edd Barrett <vex...@gmail.com> Branch: improve-errors-again Changeset: r66416:bd95e658ba19 Date: 2013-08-28 16:53 +0100 http://bitbucket.org/pypy/pypy/changeset/bd95e658ba19/
Log: (Ronan, Edd) Correctly report a couple of user-level errors. It wasn't obvious from the error message what the actual problem in the user's program was. diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py --- a/rpython/annotator/test/test_annrpython.py +++ b/rpython/annotator/test/test_annrpython.py @@ -4099,6 +4099,25 @@ assert ("RPython cannot unify incompatible iterator variants" in exc.value.msg) + def test_variable_getattr(self): + class A(object): pass + def f(y): + a = A() + return getattr(a, y) + a = self.RPythonAnnotator() + with py.test.raises(annmodel.AnnotatorError) as exc: + a.build_types(f, [str]) + assert ("variable argument to getattr" in exc.value.msg) + + def test_bad_call(self): + def f(x): + return x() + a = self.RPythonAnnotator() + with py.test.raises(annmodel.AnnotatorError) as exc: + a.build_types(f, [str]) + assert ("Cannot prove that the object is callable" in exc.value.msg) + + def g(n): return [0, 1, 2, n] diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py --- a/rpython/annotator/unaryop.py +++ b/rpython/annotator/unaryop.py @@ -157,9 +157,7 @@ return obj.call(getbookkeeper().build_args("call_args", args_s)) def call(obj, args, implicit_init=False): - #raise Exception, "cannot follow call_args%r" % ((obj, args),) - getbookkeeper().warning("cannot follow call(%r, %r)" % (obj, args)) - return SomeObject() + raise AnnotatorError("Cannot prove that the object is callable") def op_contains(obj, s_element): return s_Bool @@ -652,7 +650,7 @@ if s_attr.is_constant() and isinstance(s_attr.const, str): attr = s_attr.const return ins._true_getattr(attr) - return SomeObject() + raise AnnotatorError("A variable argument to getattr is not RPython") getattr.can_only_throw = [] def setattr(ins, s_attr, s_value): @@ -750,7 +748,8 @@ # whose length is the constant 0; so let's tentatively answer 0. return immutablevalue(0) else: - return SomeObject() # len() on a pbc? no chance + # This should probably never happen + raise AnnotatorError("Cannot call len on a pbc") # annotation of low-level types from rpython.annotator.model import SomePtr, SomeLLADTMeth _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit