gh-148442: eliminate race condition in list rich comparison#148531
gh-148442: eliminate race condition in list rich comparison#148531KowalskiThomas wants to merge 6 commits into
Conversation
cc583a3 to
3ddd03d
Compare
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Could you please add a test specific to this issue, which shows why the new behavior can be better than the old one?
For example, let list1 = [x, 1] and list2 = [0, 0], where x > 0. During comparison list1 > list2, list1[0] is replaced with 0. Currently, the result will be False, even if both old and new values of list1 are larger than list2. Add also a test with replacing list2[0].
3ddd03d to
b4ebf34
Compare
|
@serhiy-storchaka I added two tests (and rebased on main since the branch was pretty out of date). |
|
I afraid this is too heavyweight. No need to use threads if we can trigger the issue with a single thread. |
41e55ba to
9668111
Compare
|
Ah yes, that's a very good point... I just removed those tests and added two new ones that are single-threaded and do about the same thing with some... peculiar comparison operators. Also, currently the release note says... ... should I also update it to frame it better and make it clear that it's not necessarily concurrent mutation? Even though that would be the most "usual" case I believe. |
What is this PR?
This PR is a fix for #148442, where the
list's rich comparison function could return an incorrect result due a race condition in non-trivial__eq__implementations of list elements.It also updates
test_equal_operator_modifying_operandwhich would previously assert two different lists were equal; it now properly asserts they are different.list's rich comparison has a race condition for non-trivial__eq__and may return an incorrect result #148442