pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/18756/files

stylesheet" href="https://github.githubassets.com/assets/code-34e10031edc15af1.css" /> [3.8] bpo-39778: Don't traverse weak-reference lists OrderedDict's tp_traverse and tp_clear (GH-18749) by pablogsal · Pull Request #18756 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions Lib/test/test_ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,26 @@ def test_iterators_pickling(self):
self.assertEqual(list(unpickled), expected)
self.assertEqual(list(it), expected)

@support.cpython_only
def test_weakref_list_is_not_traversed(self):
# Check that the weakref list is not traversed when collecting
# OrderedDict objects. See bpo-39778 for more information.

gc.collect()

x = self.OrderedDict()
x.cycle = x

cycle = []
cycle.append(cycle)

x_ref = weakref.ref(x)
cycle.append(x_ref)

del x, cycle, x_ref

gc.collect()


class PurePythonOrderedDictSubclassTests(PurePythonOrderedDictTests):

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a crash due to incorrect handling of weak references in
``collections.OrderedDict`` classes. Patch by Pablo Galindo.
2 changes: 0 additions & 2 deletions Objects/odictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,6 @@ odict_traverse(PyODictObject *od, visitproc visit, void *arg)
_ODictNode *node;

Py_VISIT(od->od_inst_dict);
Py_VISIT(od->od_weakreflist);
_odict_FOREACH(od, node) {
Py_VISIT(_odictnode_KEY(node));
}
Expand All @@ -1466,7 +1465,6 @@ static int
odict_tp_clear(PyODictObject *od)
{
Py_CLEAR(od->od_inst_dict);
Py_CLEAR(od->od_weakreflist);
PyDict_Clear((PyObject *)od);
_odict_clear_nodes(od);
return 0;
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy