gh-110525: Add tests for internal set CAPI#110630
gh-110525: Add tests for internal set CAPI#110630serhiy-storchaka merged 4 commits intopython:mainfrom
set CAPI#110630Conversation
| NULLABLE(set); | ||
|
|
||
| rc = _PySet_NextEntry(set, &pos, &item, &hash); | ||
| if (rc == 1) { |
There was a problem hiding this comment.
What if it returns 2 or -2?
| if (rc == 1) { | |
| if (rc != 0 && rc != -1) { |
There was a problem hiding this comment.
Sorry, I don't understand this one. Right now it is defined as:
Lines 2332 to 2346 in 66a9b10
It cannot return anything except [-1, 0, 1].
Do you mean that it can return something other than [-1, 0, 1] in the future?
I think that our test case must catch this change and be adapted if needed.
This function is not documented currently.
There was a problem hiding this comment.
The purpose of the test is to verify our assumptions (that it cannot return anything except [-1, 0, 1]). Otherwise there would not be need of tests.
In future a new return can be added in the code, or refactoring can lead to returning non-initialized variable in rare case. The wrapper will successfully return None.
There was a problem hiding this comment.
Got it, I used an assertion, which is more readable in my opinion 👍
|
Thanks @sobolevn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Sorry, @sobolevn and @serhiy-storchaka, I could not cleanly backport this to |
|
Working on a backport |
|
@serhiy-storchaka looks like #108787 never got backported, so we don't have the same file structure on 3.12 |
setandfrozenset#110525