diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-06 17:04:12 (GMT) |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-06 17:04:12 (GMT) |
| commit | c61c8d7a5e2884238494a678ecd22c812b062280 (patch) | |
| tree | 3fd366f94e25c5b3d5cc9430f8fc2b7de869e782 /Lib/test/test_list.py | |
| parent | c6f0df7b2095eaf0a6d5914a043f9062f66d19f7 (diff) | |
| parent | eeb7eea1f95793437b3e251f47c98446e15fa680 (diff) | |
| download | cpython-c61c8d7a5e2884238494a678ecd22c812b062280.zip cpython-c61c8d7a5e2884238494a678ecd22c812b062280.tar.gz cpython-c61c8d7a5e2884238494a678ecd22c812b062280.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_list.py')
| -rw-r--r-- | Lib/test/test_list.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index 3510bd5..d7e6629 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -59,6 +59,17 @@ class ListTest(list_tests.CommonTest): self.assertRaises((MemoryError, OverflowError), mul, lst, n) self.assertRaises((MemoryError, OverflowError), imul, lst, n) + 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(verbose=None): support.run_unittest(ListTest) |
