]> granicus.if.org Git - python/commitdiff
#3556: test_raiseMemError consumes an insane amount of memory
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 17 Aug 2008 17:01:49 +0000 (17:01 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 17 Aug 2008 17:01:49 +0000 (17:01 +0000)
Lib/test/test_unicode.py

index b3d6907eacae70323d3e74732b063fc004fb8ff5..5d887ed92f04d05f30e8af00253711a18328844c 100644 (file)
@@ -1118,14 +1118,9 @@ class UnicodeTest(
         # when a string allocation fails with a MemoryError.
         # This used to crash the interpreter,
         # or leak references when the number was smaller.
-        try:
-            u"a" * (sys.maxint // 2 - 100)
-        except MemoryError:
-            pass
-        try:
-            u"a" * (sys.maxint // 2 - 100)
-        except MemoryError:
-            pass
+        alloc = lambda: u"a" * (sys.maxsize - 100)
+        self.assertRaises(MemoryError, alloc)
+        self.assertRaises(MemoryError, alloc)
 
 def test_main():
     test_support.run_unittest(__name__)