diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-09-21 11:24:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-21 11:24:13 (GMT) |
commit | b3a77964ea89a488fc0e920e3db6d8477279f19b (patch) | |
tree | 880d5770553aac324a7b29efdb233eca0cfbd38a /Modules/arraymodule.c | |
parent | 9adda0cdf89432386b7a04444a6199b580d287a1 (diff) | |
download | cpython-b3a77964ea89a488fc0e920e3db6d8477279f19b.zip cpython-b3a77964ea89a488fc0e920e3db6d8477279f19b.tar.gz cpython-b3a77964ea89a488fc0e920e3db6d8477279f19b.tar.bz2 |
bpo-27541: Reprs of subclasses of some classes now contain actual type name. (#3631)
Affected classes are bytearray, array, deque, defaultdict, count and repeat.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r-- | Modules/arraymodule.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 1d9a4f1..4f778a2 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2307,7 +2307,8 @@ array_repr(arrayobject *a) len = Py_SIZE(a); typecode = a->ob_descr->typecode; if (len == 0) { - return PyUnicode_FromFormat("array('%c')", (int)typecode); + return PyUnicode_FromFormat("%s('%c')", + _PyType_Name(Py_TYPE(a)), (int)typecode); } if (typecode == 'u') { v = array_array_tounicode_impl(a); @@ -2317,7 +2318,8 @@ array_repr(arrayobject *a) if (v == NULL) return NULL; - s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v); + s = PyUnicode_FromFormat("%s('%c', %R)", + _PyType_Name(Py_TYPE(a)), (int)typecode, v); Py_DECREF(v); return s; } |