bpo-27541: Reprs of subclasses of some classes now contain actual typ… · python/cpython@b3a7796 (original) (raw)
`@@ -4067,7 +4067,8 @@ static PyObject *
`
4067
4067
`count_repr(countobject *lz)
`
4068
4068
`{
`
4069
4069
`if (lz->cnt != PY_SSIZE_T_MAX)
`
4070
``
`-
return PyUnicode_FromFormat("count(%zd)", lz->cnt);
`
``
4070
`+
return PyUnicode_FromFormat("%s(%zd)",
`
``
4071
`+
_PyType_Name(Py_TYPE(lz)), lz->cnt);
`
4071
4072
``
4072
4073
`if (PyLong_Check(lz->long_step)) {
`
4073
4074
`long step = PyLong_AsLong(lz->long_step);
`
`@@ -4076,11 +4077,14 @@ count_repr(countobject *lz)
`
4076
4077
` }
`
4077
4078
`if (step == 1) {
`
4078
4079
`/* Don't display step when it is an integer equal to 1 */
`
4079
``
`-
return PyUnicode_FromFormat("count(%R)", lz->long_cnt);
`
``
4080
`+
return PyUnicode_FromFormat("%s(%R)",
`
``
4081
`+
_PyType_Name(Py_TYPE(lz)),
`
``
4082
`+
lz->long_cnt);
`
4080
4083
` }
`
4081
4084
` }
`
4082
``
`-
return PyUnicode_FromFormat("count(%R, %R)",
`
4083
``
`-
lz->long_cnt, lz->long_step);
`
``
4085
`+
return PyUnicode_FromFormat("%s(%R, %R)",
`
``
4086
`+
_PyType_Name(Py_TYPE(lz)),
`
``
4087
`+
lz->long_cnt, lz->long_step);
`
4084
4088
`}
`
4085
4089
``
4086
4090
`static PyObject *
`
`@@ -4220,9 +4224,12 @@ static PyObject *
`
4220
4224
`repeat_repr(repeatobject *ro)
`
4221
4225
`{
`
4222
4226
`if (ro->cnt == -1)
`
4223
``
`-
return PyUnicode_FromFormat("repeat(%R)", ro->element);
`
``
4227
`+
return PyUnicode_FromFormat("%s(%R)",
`
``
4228
`+
_PyType_Name(Py_TYPE(ro)), ro->element);
`
4224
4229
`else
`
4225
``
`-
return PyUnicode_FromFormat("repeat(%R, %zd)", ro->element, ro->cnt);
`
``
4230
`+
return PyUnicode_FromFormat("%s(%R, %zd)",
`
``
4231
`+
_PyType_Name(Py_TYPE(ro)), ro->element,
`
``
4232
`+
ro->cnt);
`
4226
4233
`}
`
4227
4234
``
4228
4235
`static PyObject *
`