Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! bpo-41654: Fix deallocator of MemoryError to account for subcl…
…asses
  • Loading branch information
pablogsal committed Sep 1, 2020
commit 8665c177237566a0d744713e2f3c607d31e85917
18 changes: 8 additions & 10 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,15 +1332,13 @@ def test_assert_shadowing(self):
self.fail('Expected exception')

def test_memory_error_subclasses(self):
Comment thread
pablogsal marked this conversation as resolved.
Outdated
# MemoryError instances use a freelist of objects that are
# linked using the 'dict' attribute when they are
# inactive/dead. Subclasses of MemoryError should not
# participate in the freelist schema. This test creates a
# MemoryError object and keeps it alive (therefore
# advancing the freelist) and then it creates and destroys
# a subclass object. Finally, it checks that creating a
# new MemoryError succeeds, proving that the freelist is
# not corrupted. See bpo-41654 for more information.
# bpo-41654: MemoryError instances use a freelist of objects that are
# linked using the 'dict' attribute when they are inactive/dead.
# Subclasses of MemoryError should not participate in the freelist
# schema. This test creates a MemoryError object and keeps it alive
# (therefore advancing the freelist) and then it creates and destroys a
# subclass object. Finally, it checks that creating a new MemoryError
# succeeds, proving that the freelist is not corrupted.

class TestException(MemoryError):
pass
Expand All @@ -1361,7 +1359,7 @@ class TestException(MemoryError):
except MemoryError as exc:
pass

gc.collect()
gc_collect()


class ImportErrorTests(unittest.TestCase):
Expand Down