Anonymous avatar Anonymous committed ea53163

fix for issue 3862: test_array fails FreeBSD 7 amd64

FreeBSD 7's underlying malloc() is behaves differently to earlier versions
and seriously overcommits available memory on amd64. This may affect
other 64bit platforms in some circumstances, so the scale of the
problematic test is wound back.

Patch by Mark Dickinson, reviewed by Martin von Loewis.

Comments (0)

Files changed (1)

Lib/test/test_array.py

     minitemsize = 8
 
     def test_alloc_overflow(self):
+        from sys import maxsize
         a = array.array('d', [-1]*65536)
         try:
-            a *= 65536
+            a *= maxsize//65536 + 1
         except MemoryError:
             pass
         else:
-            self.fail("a *= 2**16 didn't raise MemoryError")
+            self.fail("Array of size > maxsize created - MemoryError expected")
         b = array.array('d', [ 2.71828183, 3.14159265, -1])
         try:
-            b * 1431655766
+            b * (maxsize//3 + 1)
         except MemoryError:
             pass
         else:
-            self.fail("a * 1431655766 didn't raise MemoryError")
+            self.fail("Array of size > maxsize created - MemoryError expected")
 
 tests.append(DoubleTest)
 
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.