[pypy-svn] r72740 - pypy/branch/fix-64/pypy/rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Wed Mar 24 18:24:43 CET 2010
Author: arigo
Date: Wed Mar 24 18:24:42 2010
New Revision: 72740
Modified:
pypy/branch/fix-64/pypy/rpython/lltypesystem/lltype.py
Log:
Detect OverflowErrors and convert them to MemoryError
when building a new _array. Fixes test_rlist.py.
Modified: pypy/branch/fix-64/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/fix-64/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/fix-64/pypy/rpython/lltypesystem/lltype.py Wed Mar 24 18:24:42 2010
@@ -1494,8 +1494,13 @@
if n < 0:
raise ValueError, "negative array length"
_parentable.__init__(self, TYPE)
- self.items = [TYPE.OF._allocate(initialization=initialization, parent=self, parentindex=j)
- for j in range(n)]
+ try:
+ myrange = range(n)
+ except OverflowError:
+ raise MemoryError("definitely too many items")
+ self.items = [TYPE.OF._allocate(initialization=initialization,
+ parent=self, parentindex=j)
+ for j in myrange]
if parent is not None:
self._setparentstructure(parent, parentindex)
More information about the Pypy-commit
mailing list