[pypy-svn] r18677 - pypy/dist/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Sun Oct 16 12:52:20 CEST 2005
Author: arigo
Date: Sun Oct 16 12:52:19 2005
New Revision: 18677
Modified:
pypy/dist/pypy/objspace/std/stringobject.py
Log:
Obscure change required to catch MemoryError. Catching
it in-function doesn't work through the flow object space.
Modified: pypy/dist/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stringobject.py (original)
+++ pypy/dist/pypy/objspace/std/stringobject.py Sun Oct 16 12:52:19 2005
@@ -855,6 +855,11 @@
str = "".join([s[start + i*step] for i in range(sl)])
return W_StringObject(space, str)
+def _makebuf(length):
+ """This helper needs to be a separate function so that we can safely
+ catch the MemoryErrors that it raises."""
+ return ['\x00'] * length
+
def mul_string_times(space, w_str, w_times):
try:
mul = space.int_w(w_times)
@@ -867,7 +872,7 @@
return space.wrap("")
input_len = len(input)
try:
- buffer = [' '] * ovfcheck(mul*input_len)
+ buffer = _makebuf(ovfcheck(mul*input_len))
except (MemoryError,OverflowError,ValueError):
# ugh. ValueError is what you get on 64-bit machines for
# integers in range(2**31, 2**63).
More information about the Pypy-commit
mailing list