Issue #22824: Simplify reprlib output format for empty arrays
diff --git a/Lib/reprlib.py b/Lib/reprlib.py
index 5eb5ca3..ecbd2cc 100644
--- a/Lib/reprlib.py
+++ b/Lib/reprlib.py
@@ -83,6 +83,8 @@
return self._repr_iterable(x, level, '[', ']', self.maxlist)
def repr_array(self, x, level):
+ if not x:
+ return "array('%s')" % x.typecode
header = "array('%s', [" % x.typecode
return self._repr_iterable(x, level, header, '])', self.maxarray)
diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py
index 83f38cd..a51c4d7 100644
--- a/Lib/test/test_reprlib.py
+++ b/Lib/test/test_reprlib.py
@@ -94,7 +94,7 @@
eq(r(d), "{'alice': 1, 'arthur': 1, 'bob': 2, 'charles': 3, ...}")
# 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, 2])), "array('i', [1, 2])")
eq(r(array('i', [1, 2, 3])), "array('i', [1, 2, 3])")