Message52499
Sort of. Below is a test for 32-bit architectures. Unfortunately, on architectures where Py_ssize_t is a 64-bit integer, the multiplication won't overflow and the test really will try to build a list with 2**32 items (which most likely will eventually raise a MemoryError, but it will take a LONG time!). This is probably undesirable. Is there a way to skip this test for non-32-bit architectures?
One way would be to only perform the test if sys.maxint <= 2**31.
Below is a test that can be added to seq_tests.py:
def test_bigrepeat(self):
x = self.type2test([0])
x *= 2**16
self.assertRaises(MemoryError, x.__mul__, 2**16)
self.assertRaises(MemoryError, x.__imul__, 2**16)
While writing the test I found a bug in my patch for the case where the list is already size 0. New patch attached.
File Added: list_repeat.patch |
|
Date |
User |
Action |
Args |
2007-08-23 15:58:11 | admin | link | issue1704621 messages |
2007-08-23 15:58:11 | admin | create | |
|