Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-110525: Add tests for internalset CAPI#110630
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| NULLABLE(set); | ||
| rc=_PySet_NextEntry(set,&pos,&item,&hash); | ||
| if (rc==1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What if it returns 2 or -2?
| if (rc==1) { | |
| if (rc!=0&&rc!=-1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry, I don't understand this one. Right now it is defined as:
Lines 2332 to 2346 in66a9b10
| int | |
| _PySet_NextEntry(PyObject*set,Py_ssize_t*pos,PyObject**key,Py_hash_t*hash) | |
| { | |
| setentry*entry; | |
| if (!PyAnySet_Check(set)) { | |
| PyErr_BadInternalCall(); | |
| return-1; | |
| } | |
| if (set_next((PySetObject*)set,pos,&entry)==0) | |
| return0; | |
| *key=entry->key; | |
| *hash=entry->hash; | |
| return1; | |
| } |
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.
serhiy-storchakaOct 10, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Got it, I used an assertion, which is more readable in my opinion 👍
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
miss-islington commentedOct 10, 2023
Thanks@sobolevn for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
miss-islington commentedOct 10, 2023
Sorry,@sobolevn and@serhiy-storchaka, I could not cleanly backport this to |
sobolevn commentedOct 10, 2023
Working on a backport |
sobolevn commentedOct 10, 2023
@serhiy-storchaka looks like#108787 never got backported, so we don't have the same file structure on 3.12 |
Uh oh!
There was an error while loading.Please reload this page.
setandfrozenset#110525