Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r54051:6c98c84b301b
Date: 2012-03-28 17:47 -0700
http://bitbucket.org/pypy/pypy/changeset/6c98c84b301b/
Log: really pretty error messages
diff --git a/pypy/module/cppyy/interp_cppyy.py
b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -288,7 +288,7 @@
pass
# only get here if all overloads failed ...
- errmsg = 'None of the overloads matched:'
+ errmsg = 'none of the %d overloaded methods succeeded. Full details:'
% len(self.functions)
if hasattr(self.space, "fake"): # FakeSpace fails errorstr (see
below)
raise OperationError(self.space.w_TypeError,
self.space.wrap(errmsg))
for i in range(len(self.functions)):
@@ -296,9 +296,11 @@
try:
return cppyyfunc.call(cppthis, args_w)
except OperationError, e:
- errmsg += '\n\t'+e.errorstr(self.space)
+ errmsg += '\n '+cppyyfunc.signature()+' =>\n'
+ errmsg += ' '+e.errorstr(self.space)
except Exception, e:
- errmsg += '\n\tException:'+str(e)
+ errmsg += '\n '+cppyyfunc.signature()+' =>\n'
+ errmsg += ' Exception:'+str(e)
raise OperationError(self.space.w_TypeError, self.space.wrap(errmsg))
diff --git a/pypy/module/cppyy/test/test_fragile.py
b/pypy/module/cppyy/test/test_fragile.py
--- a/pypy/module/cppyy/test/test_fragile.py
+++ b/pypy/module/cppyy/test/test_fragile.py
@@ -172,8 +172,22 @@
d.check(None) # raises TypeError
assert 0
except TypeError, e:
+ assert "fragile::D::check()" in str(e)
assert "TypeError: wrong number of arguments" in str(e)
+ try:
+ d.overload(None) # raises TypeError
+ assert 0
+ except TypeError, e:
+ assert "fragile::D::overload()" in str(e)
+ assert "TypeError: wrong number of arguments" in str(e)
+ assert "fragile::D::overload(fragile::no_such_class*)" in str(e)
+ assert "TypeError: no converter available for type
\"fragile::no_such_class*\"" in str(e)
+ assert "fragile::D::overload(char, int)" in str(e)
+ assert "TypeError: expected string, got NoneType object" in str(e)
+ assert "fragile::D::overload(int, fragile::no_such_class*)" in
str(e)
+ assert "TypeError: unsupported operand type for int(): 'NoneType'"
in str(e)
+
j = fragile.J()
assert fragile.J.method1.__doc__ == j.method1.__doc__
assert j.method1.__doc__ == "fragile::J::method1(int, double)"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit