Commits

Armin Rigo committed 5d8f681

Don't raise MemoryError explicitly; it is not needed, and confuses
test_runner:test_memoryerror.

Comments (0)

Files changed (1)

pypy/jit/backend/llsupport/gc.py

 
     def generate_function(self, funcname, func, ARGS, RESULT=llmemory.GCREF):
         """Generates a variant of malloc with the given name and the given
-        arguments.  It should raise MemoryError and return NULL if out of
-        memory.
+        arguments.  It should return NULL if out of memory.  If it raises
+        anything, it must be an optional MemoryError.
         """
         FUNCPTR = lltype.Ptr(lltype.FuncType(ARGS, RESULT))
         descr = get_call_descr(self, ARGS, RESULT)
     def _make_functions(self):
 
         def malloc_fixedsize(size):
-            res = self.malloc_fn_ptr(size)
-            if not res:
-                raise MemoryError
-            return res
+            return self.malloc_fn_ptr(size)
         self.generate_function('malloc_fixedsize', malloc_fixedsize,
                                [lltype.Signed])
 
             try:
                 totalsize = ovfcheck(basesize + ovfcheck(itemsize * num_elem))
             except OverflowError:
-                raise MemoryError
+                return lltype.nullptr(llmemory.GCREF.TO)
             res = self.malloc_fn_ptr(totalsize)
-            if not res:
-                raise MemoryError
-            arrayptr = rffi.cast(rffi.CArrayPtr(lltype.Signed), res)
-            arrayptr[ofs_length/WORD] = num_elem
+            if res:
+                arrayptr = rffi.cast(rffi.CArrayPtr(lltype.Signed), res)
+                arrayptr[ofs_length/WORD] = num_elem
             return res
         self.generate_function('malloc_array', malloc_array,
                                [lltype.Signed] * 4)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.