| 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 | @@ -342,3 +342,11 @@ def test_list_extend(self): | |||||
|
|
||||||
| # CRASHES list_extend(NULL, []) | ||||||
| # CRASHES list_extend([], NULL) | ||||||
|
|
||||||
| def test_list_fromarraymoveref(self): | ||||||
| # Test PyList_FromArrayMoveRef() | ||||||
| list_fromarraymoveref = _testcapi.list_fromarraymoveref | ||||||
|
|
||||||
| lst = [object() for _ in range(5)] | ||||||
|
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 QualityI would use the following example:
Suggested change
Better repr.
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 QualityFirst, I used list("abdef"), but all items are immortal and so tests didn't detect refcount bugs in my C code. I used object() to make sure that each object is unique. I don't think that repr is important here, the test is not supposed to fail :-)
Sorry, something went wrong.
All reactions
|
||||||
| copy = list_fromarraymoveref(lst) | ||||||
| self.assertEqual(copy, lst) | ||||||
|
Comment thread
Comment on lines
+351
to
+352
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 QualityTest also with zero and negative size. with too large size (causing MemoryError or OverflowError), with array=NULL, and with NULLs in the array. We should know what cases raise exceptions, what cases crash and what cases are valid, and how errors are handled.
Sorry, something went wrong.
All reactions
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import unittest | ||
| from test.support import import_helper | ||
| _testcapi = import_helper.import_module('_testcapi') | ||
|
|
||
|
|
||
| class CAPITest(unittest.TestCase): | ||
| def test_tuple_fromarray(self): | ||
| # Test PyTuple_FromArray() | ||
| tuple_fromarray = _testcapi.tuple_fromarraymoveref | ||
|
|
||
| tup = tuple(object() for _ in range(5)) | ||
| copy = tuple_fromarray(tup) | ||
| self.assertEqual(copy, tup) | ||
|
|
||
| def test_tuple_fromarraymoveref(self): | ||
| # Test PyTuple_FromArrayMoveRef() | ||
| tuple_fromarraymoveref = _testcapi.tuple_fromarraymoveref | ||
|
|
||
| tup = tuple(object() for _ in range(5)) | ||
| copy = tuple_fromarraymoveref(tup) | ||
| self.assertEqual(copy, tup) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Add new functions to create :class:`tuple` and :class:`list` from arrays: | ||
|
|
||
| * :c:func:`PyTuple_FromArray`. | ||
| * :c:func:`PyTuple_FromArrayMoveRef`. | ||
| * :c:func:`PyList_FromArrayMoveRef`. | ||
|
|
||
| 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 QualitySorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.