mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue #22824: Simplify reprlib output format for empty arrays
This commit is contained in:
parent
5d43833982
commit
a34cd0c781
3 changed files with 6 additions and 1 deletions
|
@ -83,6 +83,8 @@ class Repr:
|
||||||
return self._repr_iterable(x, level, '[', ']', self.maxlist)
|
return self._repr_iterable(x, level, '[', ']', self.maxlist)
|
||||||
|
|
||||||
def repr_array(self, x, level):
|
def repr_array(self, x, level):
|
||||||
|
if not x:
|
||||||
|
return "array('%s')" % x.typecode
|
||||||
header = "array('%s', [" % x.typecode
|
header = "array('%s', [" % x.typecode
|
||||||
return self._repr_iterable(x, level, header, '])', self.maxarray)
|
return self._repr_iterable(x, level, header, '])', self.maxarray)
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ class ReprTests(unittest.TestCase):
|
||||||
eq(r(d), "{'alice': 1, 'arthur': 1, 'bob': 2, 'charles': 3, ...}")
|
eq(r(d), "{'alice': 1, 'arthur': 1, 'bob': 2, 'charles': 3, ...}")
|
||||||
|
|
||||||
# array.array after 5.
|
# array.array after 5.
|
||||||
eq(r(array('i')), "array('i', [])")
|
eq(r(array('i')), "array('i')")
|
||||||
eq(r(array('i', [1])), "array('i', [1])")
|
eq(r(array('i', [1])), "array('i', [1])")
|
||||||
eq(r(array('i', [1, 2])), "array('i', [1, 2])")
|
eq(r(array('i', [1, 2])), "array('i', [1, 2])")
|
||||||
eq(r(array('i', [1, 2, 3])), "array('i', [1, 2, 3])")
|
eq(r(array('i', [1, 2, 3])), "array('i', [1, 2, 3])")
|
||||||
|
|
|
@ -209,6 +209,9 @@ Library
|
||||||
- Issue #22824: Updated reprlib output format for sets to use set literals.
|
- Issue #22824: Updated reprlib output format for sets to use set literals.
|
||||||
Patch contributed by Berker Peksag.
|
Patch contributed by Berker Peksag.
|
||||||
|
|
||||||
|
- Issue #22824: Updated reprlib output format for arrays to display empty
|
||||||
|
arrays without an unnecessary empty list. Suggested by Serhiy Storchaka.
|
||||||
|
|
||||||
- Issue #22406: Fixed the uu_codec codec incorrectly ported to 3.x.
|
- Issue #22406: Fixed the uu_codec codec incorrectly ported to 3.x.
|
||||||
Based on patch by Martin Panter.
|
Based on patch by Martin Panter.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue