Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-111489: Add PyTuple_FromArray() function#139691
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -62,6 +62,28 @@ def test_tuple_new(self): | ||
| self.assertRaises(SystemError, tuple_new, PY_SSIZE_T_MIN) | ||
| self.assertRaises(MemoryError, tuple_new, PY_SSIZE_T_MAX) | ||
| def test_tuple_fromarray(self): | ||
| # Test PyTuple_FromArray() | ||
| tuple_fromarray = _testcapi.tuple_fromarray | ||
| tup = tuple([i] for i in range(5)) | ||
| copy = tuple_fromarray(tup) | ||
| self.assertEqual(copy, tup) | ||
| tup = () | ||
| copy = tuple_fromarray(tup) | ||
| self.assertIs(copy, tup) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is not the empty tuple singleton a CPython implementation detail? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole file is a CPython implementation detail (_testcapi), no? | ||
| copy = tuple_fromarray(NULL, 0) | ||
| self.assertIs(copy, ()) | ||
| with self.assertRaises(SystemError): | ||
| tuple_fromarray(NULL, -1) | ||
| with self.assertRaises(SystemError): | ||
| tuple_fromarray(NULL, PY_SSIZE_T_MIN) | ||
| with self.assertRaises(MemoryError): | ||
| tuple_fromarray(NULL, PY_SSIZE_T_MAX) | ||
| def test_tuple_pack(self): | ||
| # Test PyTuple_Pack() | ||
| pack = _testlimitedcapi.tuple_pack | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Add :c:func:`PyTuple_FromArray` to create a :class:`tuple` from an array. | ||
| Patch by Victor Stinner. |
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.
I would prefer to formulate this in words more similar to
PyTuple_New()orPyTuple_Pack()("Return a new tuple object of size ... "), but this is not so important.