| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -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) | ||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs not the empty tuple singleton a CPython implementation detail?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe whole file is a CPython implementation detail (_testcapi), no?
Sorry, something went wrong.
All reactions
|
||
|
|
||
| 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 | ||
| Expand Down | ||
| 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. |
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI would prefer to formulate this in words more similar to PyTuple_New() or PyTuple_Pack() ("Return a new tuple object of size ... "), but this is not so important.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.