summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tuple.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-10-06 16:57:27 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-10-06 16:57:27 (GMT)
commiteeb7eea1f95793437b3e251f47c98446e15fa680 (patch)
treee83a45f7eddbc424f375a89581a918baf2a42dcd /Lib/test/test_tuple.py
parentbb2095f1e273d06f7dfaa8303c46ce6f01212c76 (diff)
downloadcpython-eeb7eea1f95793437b3e251f47c98446e15fa680.zip
cpython-eeb7eea1f95793437b3e251f47c98446e15fa680.tar.gz
cpython-eeb7eea1f95793437b3e251f47c98446e15fa680.tar.bz2
Issue #12911: Fix memory consumption when calculating the repr() of huge tuples or lists.
This introduces a small private API for this common pattern. The issue has been discovered thanks to Martin's huge-mem buildbot.
Diffstat (limited to 'Lib/test/test_tuple.py')
-rw-r--r--Lib/test/test_tuple.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
index 75fbe45..1464a0e 100644
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -154,6 +154,16 @@ class TupleTest(seq_tests.CommonTest):
# Trying to untrack an unfinished tuple could crash Python
self._not_tracked(tuple(gc.collect() for i in range(101)))
+ def test_repr_large(self):
+ # Check the repr of large list objects
+ def check(n):
+ l = (0,) * n
+ s = repr(l)
+ self.assertEqual(s,
+ '(' + ', '.join(['0'] * n) + ')')
+ check(10) # check our checking code
+ check(1000000)
+
def test_main():
support.run_unittest(TupleTest)