diff options
author | 2024-01-06 13:20:51 +0100 | |
---|---|---|
committer | 2024-01-06 13:21:50 +0100 | |
commit | 9a834363ba7abb977bddb9b18b67ac0be36fb410 (patch) | |
tree | 665ba2f65108d0fca516e56d5e369202e311c24b | |
parent | remove two more references to clever_malloc_removal (diff) | |
download | pypy-9a834363ba7abb977bddb9b18b67ac0be36fb410.tar.gz pypy-9a834363ba7abb977bddb9b18b67ac0be36fb410.tar.bz2 pypy-9a834363ba7abb977bddb9b18b67ac0be36fb410.zip |
memory check fix for running on pypy
on pypy2, range(sys.maxint) works and doesn't raise MemoryError (nor
OverflowError). so we check whether size is reasonable by allocating a
dummy list of that size first. should fix the occasional segfault of
test_memoryerror in rpython.rtyper.test.test_rlist
-rw-r--r-- | rpython/rtyper/lltypesystem/lltype.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py index 5871d3a321..cd838ac776 100644 --- a/rpython/rtyper/lltypesystem/lltype.py +++ b/rpython/rtyper/lltypesystem/lltype.py @@ -1882,6 +1882,9 @@ class _array(_parentable): # checks that it's ok to make an array of size 'n', and returns # range(n). Explicitly overridden by some tests. try: + # first check it's a reasonable amount of memory + # because range lists don't take much space on pypy + [0] * n return range(n) except OverflowError: raise MemoryError("definitely too many items") |