diff --git a/Lib/test/test_cinder.py b/Lib/test/test_cinder.py index f17d0c5c421..fcc41835f3f 100644 --- a/Lib/test/test_cinder.py +++ b/Lib/test/test_cinder.py @@ -167,7 +167,7 @@ class D: del D.foo def test_type_freeze_bad_arg(self): - with self.assertRaisesRegex(TypeError, "freeze_type requires a type"): + with self.assertRaisesRegex(TypeError, "freeze_type requires a type, got int"): cinder.freeze_type(42) def test_cached_class_prop(self): diff --git a/Modules/_cinder.c b/Modules/_cinder.c index c8d4c268eac..6ea2f6a1b67 100644 --- a/Modules/_cinder.c +++ b/Modules/_cinder.c @@ -88,9 +88,11 @@ static PyObject * cinder_freeze_type(PyObject *self, PyObject *o) { if (!PyType_Check(o)) { - PyErr_SetString( + PyErr_Format( PyExc_TypeError, - "freeze_type requires a type"); + "freeze_type requires a type, got %s", + Py_TYPE(o)->tp_name + ); return NULL; } ((PyTypeObject*)o)->tp_flags |= Ci_Py_TPFLAGS_FROZEN; @@ -109,9 +111,11 @@ static PyObject * cinder_warn_on_inst_dict(PyObject *self, PyObject *o) { if (!PyType_Check(o)) { - PyErr_SetString( + PyErr_Format( PyExc_TypeError, - "warn_on_inst_dict requires a type"); + "warn_on_inst_dict requires a type, got %s", + Py_TYPE(o)->tp_name + ); return NULL; } else if (((PyTypeObject *)o)->tp_flags & Ci_Py_TPFLAGS_FROZEN) { PyErr_SetString(