summaryrefslogtreecommitdiff
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-07-31 23:39:05 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-07-31 23:39:05 +0000
commit06847b13ca28ef88e0ded4ce985c46317ba8cdaf (patch)
tree538beea91ca49f9cfeb724c4de85824cb45a2f4d /Lib/test/test_unicode.py
parentad9604003ccfcf956375bbc2aeaac078b7bc9b23 (diff)
downloadcpython-git-06847b13ca28ef88e0ded4ce985c46317ba8cdaf.tar.gz
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.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index f825353173..b3d6907eac 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1113,6 +1113,20 @@ class UnicodeTest(
# will fail
self.assertRaises(UnicodeEncodeError, "foo{0}".format, u'\u1000bar')
+ 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:
+ u"a" * (sys.maxint // 2 - 100)
+ except MemoryError:
+ pass
+ try:
+ u"a" * (sys.maxint // 2 - 100)
+ except MemoryError:
+ pass
+
def test_main():
test_support.run_unittest(__name__)