Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r682:36da3efc1834 Date: 2012-07-26 12:59 +0200 http://bitbucket.org/cffi/cffi/changeset/36da3efc1834/
Log: Simplify this error message diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -1648,7 +1648,7 @@ if (cif_descr != NULL) { /* regular case: this function does not take '...' arguments */ if (nargs != nargs_declared) { - errormsg = "%s expects %zd arguments, got %zd"; + errormsg = "'%s' expects %zd arguments, got %zd"; goto bad_number_of_arguments; } } @@ -1656,7 +1656,7 @@ /* call of a variadic function */ ffi_abi fabi; if (nargs < nargs_declared) { - errormsg = "%s expects at least %zd arguments, got %zd"; + errormsg = "'%s' expects at least %zd arguments, got %zd"; goto bad_number_of_arguments; } fvarargs = PyTuple_New(nargs); @@ -1784,16 +1784,8 @@ return res; bad_number_of_arguments: - { - PyObject *s = Py_TYPE(cd)->tp_repr((PyObject *)cd); - if (s != NULL) { - PyErr_Format(PyExc_TypeError, errormsg, - PyString_AS_STRING(s), nargs_declared, nargs); - Py_DECREF(s); - } - goto error; - } - + PyErr_Format(PyExc_TypeError, errormsg, + cd->c_type->ct_name, nargs_declared, nargs); error: if (buffer) PyObject_Free(buffer); diff --git a/c/test_c.py b/c/test_c.py --- a/c/test_c.py +++ b/c/test_c.py @@ -862,7 +862,7 @@ assert repr(f).startswith( "<cdata 'int(*)(int)' calling <function cb at 0x") e = py.test.raises(TypeError, f) - assert str(e.value) == "%r expects 1 arguments, got 0" % (f,) + assert str(e.value) == "'int(*)(int)' expects 1 arguments, got 0" def test_callback_return_type(): for rettype in ["signed char", "short", "int", "long", "long long", _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit