gh-111140: Improve PyLong_AsNativeBytes API doc example & improve the test by gpshead · Pull Request #115380 · python/cpython
added 2 commits
This also makes the example more realistic, people are unlikely to want this API to get a value into a simple `int` type, we've got direct APIs for that. So have the example use an array as if it is a bignum of its own. I start by fixing the API name in the doc example as scoder@ noted in the original code review after merge. But I noticed one thing in the test that could be done better so I added that as well: we need to guarantee that all bytes of the result are overwritten. This now pre-fills the result with data in order to ensure that. _(assuming ctypes isn't undoing that behind the scenes...)_
gpshead
marked this pull request as ready for review
gpshead
changed the title
gh-11140: Correct AsNativeBytes API docs & improve the test
gh-11140: Improve PyLong_AsNativeBytes API doc example & improve the test
zooba
changed the title
gh-11140: Improve PyLong_AsNativeBytes API doc example & improve the test
gh-111140: Improve PyLong_AsNativeBytes API doc example & improve the test
gpshead
marked this pull request as ready for review
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request
…ve the test (python#115380) This expands the examples to cover both realistic use cases for the API. I noticed thing in the test that could be done better so I added those as well: We need to guarantee that all bytes of the result are overwritten and that too many are not written. Tests now pre-fills the result with data in order to ensure that. Co-authored-by: Steve Dower <steve.dower@microsoft.com>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request
…ve the test (python#115380) This expands the examples to cover both realistic use cases for the API. I noticed thing in the test that could be done better so I added those as well: We need to guarantee that all bytes of the result are overwritten and that too many are not written. Tests now pre-fills the result with data in order to ensure that. Co-authored-by: Steve Dower <steve.dower@microsoft.com>
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request
…ve the test (python#115380) This expands the examples to cover both realistic use cases for the API. I noticed thing in the test that could be done better so I added those as well: We need to guarantee that all bytes of the result are overwritten and that too many are not written. Tests now pre-fills the result with data in order to ensure that. Co-authored-by: Steve Dower <steve.dower@microsoft.com>