Skip to content
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

[3.9] bpo-46615: Don't crash when set operations mutate the sets (GH-31120) #31312

Merged
merged 1 commit into from
Feb 13, 2022

Conversation

sweeneyde
Copy link
Member

@sweeneyde sweeneyde commented Feb 13, 2022

Ensure strong references are acquired whenever using set_next(). Added randomized test cases for __eq__ methods that sometimes mutate sets when called.

(cherry picked from commit 4a66615)

https://bugs.python.org/issue46615

…31120)

Ensure strong references are acquired whenever using `set_next()`. Added randomized test cases for `__eq__` methods that sometimes mutate sets when called.

(cherry picked from commit 4a66615)
@@ -1515,17 +1529,21 @@ set_difference(PySetObject *so, PyObject *other)
while (set_next(so, &pos, &entry)) {
key = entry->key;
hash = entry->hash;
Py_INCREF(key);
rv = _PyDict_Contains(other, key, hash);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: cherry-picker only struggled because this is _PyDict_Contains_KnownHash() in main.

@serhiy-storchaka serhiy-storchaka merged commit c31b8a9 into python:3.9 Feb 13, 2022
@sweeneyde sweeneyde deleted the backport-4a66615-3.9 branch February 13, 2022 18:18
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…31120) (pythonGH-31312)

Ensure strong references are acquired whenever using `set_next()`. Added randomized test cases for `__eq__` methods that sometimes mutate sets when called.

(cherry picked from commit 4a66615)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants