[pypy-svn] r51824 - in pypy/dist/pypy/translator: jvm jvm/src/pypy oosupport/test_template

niko at codespeak.net niko at codespeak.net
Sat Feb 23 14:30:45 CET 2008


Author: niko
Date: Sat Feb 23 14:30:45 2008
New Revision: 51824

Modified:
   pypy/dist/pypy/translator/jvm/prebuiltnodes.py
   pypy/dist/pypy/translator/jvm/src/pypy/Interlink.java
   pypy/dist/pypy/translator/oosupport/test_template/extreme.py
Log:
fix out of memory error and incldue a include a test

Modified: pypy/dist/pypy/translator/jvm/prebuiltnodes.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/prebuiltnodes.py	(original)
+++ pypy/dist/pypy/translator/jvm/prebuiltnodes.py	Sat Feb 23 14:30:45 2008
@@ -26,6 +26,10 @@
     raise RuntimeError
 
 @with_types([])
+def throwMemoryError():
+    raise MemoryError
+
+ at with_types([])
 def throwValueError():
     raise ValueError
 

Modified: pypy/dist/pypy/translator/jvm/src/pypy/Interlink.java
==============================================================================
--- pypy/dist/pypy/translator/jvm/src/pypy/Interlink.java	(original)
+++ pypy/dist/pypy/translator/jvm/src/pypy/Interlink.java	Sat Feb 23 14:30:45 2008
@@ -14,6 +14,7 @@
     public void throwIndexError();
     public void throwOverflowError();
     public void throwRuntimeError();
+    public void throwMemoryError();
     public void throwValueError();
     public void throwUnicodeDecodeError();
     public void throwOSError(int errCode);

Modified: pypy/dist/pypy/translator/oosupport/test_template/extreme.py
==============================================================================
--- pypy/dist/pypy/translator/oosupport/test_template/extreme.py	(original)
+++ pypy/dist/pypy/translator/oosupport/test_template/extreme.py	Sat Feb 23 14:30:45 2008
@@ -3,13 +3,16 @@
 class BaseTestExtreme:
 
     def test_memoryerror_due_to_oom(self):
-        py.test.skip("can't get MemoryError except block to show up")
+        def relentless_memory_consumption_machine():
+            lst = []
+            while True: lst.append([])
+            
         def fn():
             try:
-                lst = []
-                for i in range(sys.maxint): lst.append(i)
+                relentless_memory_consumption_machine()
             except MemoryError:
                 return "OK"
+            return "How much memory do you HAVE??"
         assert self.interpret(fn, []) == "OK"
         
     def test_runtimeerror_due_to_stack_overflow(self):



More information about the Pypy-commit mailing list