mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
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.
This commit is contained in:
parent
ad9604003c
commit
06847b13ca
2 changed files with 17 additions and 1 deletions
|
|
@ -1113,6 +1113,20 @@ def __format__(self, format_spec):
|
|||
# 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__)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue