@@ -133,7 +133,7 @@ PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
133133 }
134134 if (!PyLong_Check (result )) {
135135 PyErr_Format (PyExc_TypeError ,
136- "%T.__length_hint__() must return type int ( not %T) " ,
136+ "%T.__length_hint__() must return an int, not %T" ,
137137 o , result );
138138 Py_DECREF (result );
139139 return -1 ;
@@ -145,7 +145,7 @@ PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
145145 }
146146 if (res < 0 ) {
147147 PyErr_Format (PyExc_ValueError ,
148- "%T.__length_hint__() must return positive int" , o );
148+ "%T.__length_hint__() must return a positive int" , o );
149149 return -1 ;
150150 }
151151 return res ;
@@ -889,7 +889,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec)
889889
890890 if (result && !PyUnicode_Check (result )) {
891891 PyErr_Format (PyExc_TypeError ,
892- "%T.__format__() must return type str ( not %T) " ,
892+ "%T.__format__() must return a str, not %T" ,
893893 obj , result );
894894 Py_SETREF (result , NULL );
895895 goto done ;
@@ -1423,14 +1423,14 @@ _PyNumber_Index(PyObject *item)
14231423
14241424 if (!PyLong_Check (result )) {
14251425 PyErr_Format (PyExc_TypeError ,
1426- "%T.__index__() must return type int ( not %T) " ,
1426+ "%T.__index__() must return an int, not %T" ,
14271427 item , result );
14281428 Py_DECREF (result );
14291429 return NULL ;
14301430 }
14311431 /* Issue #17576: warn if 'result' not of exact type int. */
14321432 if (PyErr_WarnFormat (PyExc_DeprecationWarning , 1 ,
1433- "%T.__index__() must return type int ( not %T) . "
1433+ "%T.__index__() must return an int, not %T. "
14341434 "The ability to return an instance of a strict subclass of int "
14351435 "is deprecated, and may be removed in a future version of Python." ,
14361436 item , result )) {
@@ -1533,14 +1533,14 @@ PyNumber_Long(PyObject *o)
15331533
15341534 if (!PyLong_Check (result )) {
15351535 PyErr_Format (PyExc_TypeError ,
1536- "%T.__int__() must return type int ( not %T) " ,
1536+ "%T.__int__() must return an int, not %T" ,
15371537 o , result );
15381538 Py_DECREF (result );
15391539 return NULL ;
15401540 }
15411541 /* Issue #17576: warn if 'result' not of exact type int. */
15421542 if (PyErr_WarnFormat (PyExc_DeprecationWarning , 1 ,
1543- "%T.__int__() must return type int ( not %T) . "
1543+ "%T.__int__() must return an int, not %T. "
15441544 "The ability to return an instance of a strict subclass of int "
15451545 "is deprecated, and may be removed in a future version of Python." ,
15461546 o , result )) {
@@ -1611,13 +1611,13 @@ PyNumber_Float(PyObject *o)
16111611
16121612 if (!PyFloat_Check (res )) {
16131613 PyErr_Format (PyExc_TypeError ,
1614- "%T.__float__() must return type float ( not %T) " , o , res );
1614+ "%T.__float__() must return a float, not %T" , o , res );
16151615 Py_DECREF (res );
16161616 return NULL ;
16171617 }
16181618 /* Issue #26983: warn if 'res' not of exact type float. */
16191619 if (PyErr_WarnFormat (PyExc_DeprecationWarning , 1 ,
1620- "%T.__float__() must return type float ( not %T) . "
1620+ "%T.__float__() must return a float, not %T. "
16211621 "The ability to return an instance of a strict subclass of float "
16221622 "is deprecated, and may be removed in a future version of Python." ,
16231623 o , res )) {
@@ -2436,7 +2436,7 @@ method_output_as_list(PyObject *o, PyObject *meth)
24362436 PyThreadState * tstate = _PyThreadState_GET ();
24372437 if (_PyErr_ExceptionMatches (tstate , PyExc_TypeError )) {
24382438 _PyErr_Format (tstate , PyExc_TypeError ,
2439- "%T.%U() must return type iterable ( not %T) " ,
2439+ "%T.%U() must return an iterable, not %T" ,
24402440 o , meth , meth_output );
24412441 }
24422442 Py_DECREF (meth_output );
@@ -2817,7 +2817,7 @@ PyObject_GetIter(PyObject *o)
28172817 PyObject * res = (* f )(o );
28182818 if (res != NULL && !PyIter_Check (res )) {
28192819 PyErr_Format (PyExc_TypeError ,
2820- "%T.iter() must return type iterator of type '%T' " ,
2820+ "%T.iter() must return an iterator, not %T " ,
28212821 o , res );
28222822 Py_SETREF (res , NULL );
28232823 }
@@ -2837,7 +2837,7 @@ PyObject_GetAIter(PyObject *o) {
28372837 PyObject * it = (* f )(o );
28382838 if (it != NULL && !PyAIter_Check (it )) {
28392839 PyErr_Format (PyExc_TypeError ,
2840- "%T.aiter() must return type async iterator of type '%T' " ,
2840+ "%T.aiter() must return an async iterator, not %T " ,
28412841 o , it );
28422842 Py_SETREF (it , NULL );
28432843 }
0 commit comments