@@ -1071,8 +1071,9 @@ string_contains(PyObject *str_obj, PyObject *sub_obj)
10711071 return PyUnicode_Contains (str_obj , sub_obj );
10721072#endif
10731073 if (!PyString_Check (sub_obj )) {
1074- PyErr_SetString (PyExc_TypeError ,
1075- "'in <string>' requires string as left operand" );
1074+ PyErr_Format (PyExc_TypeError ,
1075+ "'in <string>' requires string as left operand, "
1076+ "not %.200s" , sub_obj -> ob_type -> tp_name );
10761077 return -1 ;
10771078 }
10781079 }
@@ -1240,8 +1241,9 @@ string_subscript(PyStringObject* self, PyObject* item)
12401241 }
12411242 }
12421243 else {
1243- PyErr_SetString (PyExc_TypeError ,
1244- "string indices must be integers" );
1244+ PyErr_Format (PyExc_TypeError ,
1245+ "string indices must be integers, not %.200s" ,
1246+ item -> ob_type -> tp_name );
12451247 return NULL ;
12461248 }
12471249}
@@ -4148,7 +4150,8 @@ formatfloat(char *buf, size_t buflen, int flags,
41484150 double x ;
41494151 x = PyFloat_AsDouble (v );
41504152 if (x == -1.0 && PyErr_Occurred ()) {
4151- PyErr_SetString (PyExc_TypeError , "float argument required" );
4153+ PyErr_Format (PyExc_TypeError , "float argument required, "
4154+ "not %.200s" , v -> ob_type -> tp_name );
41524155 return -1 ;
41534156 }
41544157 if (prec < 0 )
@@ -4343,7 +4346,8 @@ formatint(char *buf, size_t buflen, int flags,
43434346
43444347 x = PyInt_AsLong (v );
43454348 if (x == -1 && PyErr_Occurred ()) {
4346- PyErr_SetString (PyExc_TypeError , "int argument required" );
4349+ PyErr_Format (PyExc_TypeError , "int argument required, not %.200s" ,
4350+ v -> ob_type -> tp_name );
43474351 return -1 ;
43484352 }
43494353 if (x < 0 && type == 'u' ) {
0 commit comments