8000 gh-119004: fix a crash in equality testing between `OrderedDict` by picnixz · Pull Request #121329 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119004: fix a crash in equality testing between OrderedDict #121329

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 19 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
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
Next Next commit
remove un-necessary comments
  • Loading branch information
picnixz committed Jul 22, 2024
commit 8815a17e7d8b0db2fd3b41bde22965e0ea99a02d
4 changes: 0 additions & 4 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,6 @@ anywhere a regular dictionary is used.
.. versionchanged:: 3.9
Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`.

.. versionchanged:: 3.14
Mutating :class:`OrderedDict` objects during an equality comparison raises
a :exc:`RuntimeError`.


:class:`OrderedDict` Examples and Recipes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 0 additions & 7 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,6 @@ def __eq__(self, other):
while comparison to a regular mapping is order-insensitive.

'''
# The Python implementation differs from the C implementation in the
# sense that it does not track mutations occurring in __eq__() of keys
# or values.
#
# Since it was decided not to change the Python implementation,
# calling ``del self[key]`` in the ``key.__class__.__eq__`` may
# raise an AttributeError during iteration.
if isinstance(other, OrderedDict):
return dict.__eq__(self, other) and all(map(_eq, self, other))
return dict.__eq__(self, other)
Expand Down
4 changes: 2 additions & 2 deletions Objects/odictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)

_odictnode_KEY(node) = key;
_odictnode_HASH(node) = hash;
_odict_add_tail(od, node); // this updates 'od_state'
_odict_add_tail(od, node);
od->od_fast_nodes[i] = node;
return 0;
}
Expand Down 588C Expand Up @@ -773,7 +773,7 @@ _odict_clear_node(PyODictObject *od, _ODictNode *node, PyObject *key,

// Now clear the node.
od->od_fast_nodes[i] = NULL;
_odict_remove_node(od, node); // this updates 'od_state'
_odict_remove_node(od, node);
_odictnode_DEALLOC(node);
return 0;
}
Expand Down
0