reduce number of distinct error format strings a bit
authorStefan Behnel <stefan_ml@behnel.de>
Sun, 6 Oct 2013 09:58:23 +0000 (11:58 +0200)
committerStefan Behnel <stefan_ml@behnel.de>
Sun, 6 Oct 2013 09:58:23 +0000 (11:58 +0200)
Cython/Utility/Builtins.c
Cython/Utility/TypeConversion.c
tests/run/struct_conversion.pyx

index 814177a..92dc753 100644 (file)
@@ -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);
index 67c4894..f2c3a6e 100644 (file)
@@ -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;
     }
 
index 6106746..656049e 100644 (file)
@@ -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):
        ...