gh-136300: Modify C tests to conform to PEP-737 (GH-136301) · python/cpython@7de8ea7

GitHub

Original file line numberDiff line numberDiff line change@@ -1855,8 +1855,7 @@ ndarray_subscript(PyObject *op, PyObject *key)

1855185518561856type_error:

18571857PyErr_Format(PyExc_TypeError,

1858-"cannot index memory using \"%.200s\"",

1859-Py_TYPE(key)->tp_name);

1858+"cannot index memory using \"%T\"", key);

18601859err_occurred:

18611860Py_DECREF(nd);

18621861returnNULL;

Original file line numberDiff line numberDiff line change@@ -109,7 +109,7 @@ static PyTypeObject PyCodeLike_Type = {

109109};

110110111111#defineRAISE_UNLESS_CODELIKE(v) if (!Py_IS_TYPE((v), &PyCodeLike_Type)) { \

112- PyErr_Format(PyExc_TypeError, "expected a code-like, got %s", Py_TYPE(v)->tp_name); \

112+ PyErr_Format(PyExc_TypeError, "expected a code-like, got %T", v); \

113113 return NULL; \

114114 }

115115Original file line numberDiff line numberDiff line change@@ -5,8 +5,7 @@ static int

55pytime_from_nanoseconds(PyTime_t*tp, PyObject*obj)

66{

77if (!PyLong_Check(obj)) {

8-PyErr_Format(PyExc_TypeError, "expect int, got %s",

9-Py_TYPE(obj)->tp_name);

8+PyErr_Format(PyExc_TypeError, "expect int, got %T", obj);

109return-1;

1110 }

1211Original file line numberDiff line numberDiff line change@@ -515,8 +515,7 @@ test_thread_state(PyObject *self, PyObject *args)

515515returnNULL;

516516517517if (!PyCallable_Check(fn)) {

518-PyErr_Format(PyExc_TypeError, "'%s' object is not callable",

519-Py_TYPE(fn)->tp_name);

518+PyErr_Format(PyExc_TypeError, "'%T' object is not callable", fn);

520519returnNULL;

521520 }

522521Original file line numberDiff line numberDiff line change@@ -2207,8 +2207,7 @@ get_code(PyObject *obj)

22072207return (PyCodeObject*)PyFunction_GetCode(obj);

22082208 }

22092209return (PyCodeObject*)PyErr_Format(

2210-PyExc_TypeError, "expected function or code object, got %s",

2211-Py_TYPE(obj)->tp_name);

2210+PyExc_TypeError, "expected function or code object, got %T", obj);

22122211}

2213221222142213staticPyObject*