diff Lib/test/test_unicode.py @ 48601:a476ef5eebad

Merged revisions 65339-65340,65342 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r65339 | amaury.forgeotdarc | 2008-07-31 23:28:03 +0200 (jeu., 31 juil. 2008) | 5 lines #3479: unichr(2**32) used to return u'\x00'. The argument was fetched in a long, but PyUnicode_FromOrdinal takes an int. (why doesn't gcc issue a truncation warning in this case?) ........ r65340 | amaury.forgeotdarc | 2008-07-31 23:35:03 +0200 (jeu., 31 juil. 2008) | 2 lines Remove a dummy test that was checked in by mistake ........ r65342 | amaury.forgeotdarc | 2008-08-01 01:39:05 +0200 (ven., 01 août 2008) | 8 lines Correct a crash when two successive unicode allocations fail with a MemoryError: the freelist contained half-initialized objects with freed pointers. The comment /* XXX UNREF/NEWREF interface should be more symmetrical */ was copied from tupleobject.c, and appears in some other places. I sign the petition. ........
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Fri, 01 Aug 2008 01:06:32 +0000
parents 862c0eab1c50
children 1d88ad5f4def
line wrap: on
line diff
--- a/Lib/test/test_unicode.py	Fri Aug 01 00:14:22 2008 +0000
+++ b/Lib/test/test_unicode.py	Fri Aug 01 01:06:32 2008 +0000
@@ -1156,6 +1156,20 @@
         self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize)
 
 
+    def test_raiseMemError(self):
+        # Ensure that the freelist contains a consistent object, even
+        # when a string allocation fails with a MemoryError.
+        # This used to crash the interpreter,
+        # or leak references when the number was smaller.
+        try:
+            "a" * (sys.maxsize // 2 - 100)
+        except MemoryError:
+            pass
+        try:
+            "a" * (sys.maxsize // 2 - 100)
+        except MemoryError:
+            pass
+
 def test_main():
     support.run_unittest(__name__)