-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-110525: Add CAPI tests for set
and frozenset
objects
#110526
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
Conversation
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.
Nice.
Please test also with non-hashable items, non-set as the first argument, NULLs for any argument. If some call crashes, add a comment.
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.
I was never comfortable with _testcapi having fun with changing C API names. We cannot simply use PySet_New() name in _testcapi and in the test? I would make it more obvious that the test is on... PySet_New().
|
||
class TestSetCAPI(unittest.TestCase): | ||
def assertImmutable(self, action, *args): | ||
self.assertRaises(SystemError, action, frozenset(), *args) |
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.
SystemError? That's a surprising error. Usually, it's used when the C API is misused, like passing NULL or the wrong type. frozenset is a "wrong type" here?
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.
Yes, immutable frozenset is a wrong type for mutation-based functions :)
I think that this is intentional, because we don't really call So, I would prefer to keep this naming convention. |
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.
LGTM. Thank you @sobolevn for your PR.
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
|
Should I do a manual backport? |
It would be nice. Otherwise I will do it. |
…ythonGH-110526). (cherry picked from commit c49edd7) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
GH-110547 is a backport of this pull request to the 3.12 branch. |
Heavily inspired by https://github.com/python/cpython/blob/main/Modules/_testcapi/dict.c
set
andfrozenset
#110525