From: Stefan Behnel Date: Sun, 6 Oct 2013 09:58:23 +0000 (+0200) Subject: reduce number of distinct error format strings a bit X-Git-Tag: 0.20b1~282^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94f7b0ebf8b31d9f479c8d1da46f2ff78fec3aaa;p=platform%2Fupstream%2Fpython-cython.git reduce number of distinct error format strings a bit --- diff --git a/Cython/Utility/Builtins.c b/Cython/Utility/Builtins.c index 814177a..92dc753 100644 --- a/Cython/Utility/Builtins.c +++ b/Cython/Utility/Builtins.c @@ -201,7 +201,7 @@ static PyObject* __Pyx_Intern(PyObject* s); /* proto */ static PyObject* __Pyx_Intern(PyObject* s) { if (!(likely(PyString_CheckExact(s)))) { - PyErr_Format(PyExc_TypeError, "Expected str, got %s", Py_TYPE(s)->tp_name); + PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(s)->tp_name); return 0; } Py_INCREF(s); diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c index 67c4894..f2c3a6e 100644 --- a/Cython/Utility/TypeConversion.c +++ b/Cython/Utility/TypeConversion.c @@ -288,7 +288,7 @@ static {{struct_type_decl}} {{funcname}}(PyObject * o) { PyObject *value = NULL; if (!PyMapping_Check(o)) { - PyErr_Format(PyExc_TypeError, "Expected a mapping, not %s", o->ob_type->tp_name); + PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "a mapping", Py_TYPE(o)->tp_name); goto bad; } diff --git a/tests/run/struct_conversion.pyx b/tests/run/struct_conversion.pyx index 6106746..656049e 100644 --- a/tests/run/struct_conversion.pyx +++ b/tests/run/struct_conversion.pyx @@ -87,7 +87,7 @@ def test_obj_to_struct(MyStruct mystruct): >>> test_obj_to_struct(None) Traceback (most recent call last): ... - TypeError: Expected a mapping, not NoneType + TypeError: Expected a mapping, got NoneType >>> test_obj_to_struct(dict(s=b"world")) Traceback (most recent call last): ...