8000 bpo-42536: GC track recycled tuples by brandtbucher · Pull Request #23623 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42536: GC track recycled tuples #23623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Dec 5, 2020
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Next Next commit
Add failing regression test for OrderedDict.items
  • Loading branch information
brandtbucher committed Dec 4, 2020
commit f0aee473c97891e02708f7ef2830cfb2ade48ec1
11 changes: 11 additions & 0 deletions Lib/test/test_ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,17 @@ def test_merge_operator(self):
with self.assertRaises(ValueError):
a |= "BAD"

@support.cpython_only
def test_ordered_dict_items_result_gc(self):
# bpo-42536: OrderedDict.item's tuple-reuse speed trick breaks the GC's
# assumptions about what can be un-tracked. Make sure we re-track result
# tuples whenever we reuse them.
i = iter(self.OrderedDict({None: []}).items())
gc.collect()
# That GC collection probably untracked the recycled internal result
# tuple, which is initialized to (None, None). Make sure it's re-tracked
# when it's mutated and returned from __next__:
self.assertTrue(gc.is_tracked(next(i)))

class PurePythonOrderedDictTests(OrderedDictTests, unittest.TestCase):

Expand Down
0