-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-102471, PEP 757: Add PyLong import and export API #121339
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
Changes from 1 commit
f4fdbf2
c2e568e
f0d9525
b19764f
6f7fd11
080e079
1a7902f
b70a6dd
07552a7
0d0f942
762c33a
20be7a3
d92bf1e
b3b02a2
caca2d7
4221a49
37b1d49
d70a121
4aa25f6
90973d4
5d3e224
c7d7cb2
a3d601a
c049268
06b196b
3e8d296
86c68c2
a8fd669
a04f9d0
b2be94a
ca98ad1
167d75e
5e53a5b
c24789f
0422f9d
a529a48
3db44f3
1d2863e
d663511
816798d
033bd65
36b87d4
94d852e
a72ff83
53d584b
577598a
b08cd55
eaebef3
03248c7
0a26f97
88a62fe
45517ab
92007d1
6d3cb80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6853,20 +6853,24 @@ PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits) | |
{ | ||
if (ndigits <= 0) { | ||
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. Why not allow 0? 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. @gpshead asked to reject this case: https://discuss.python.org/t/pep-757-c-api-to-import-export-python-integers/63895/74 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. Actually, he asked to document that case (i.e. when ndigits==0). We don't think it's a good idea to overbloat docs with this edge case (different functions should be used for small integers). PEP has a dedicated section to discuss import for small integers, suggesting different functions. (In fact, the whole API is about import/export for big integers.) |
||
PyErr_SetString(PyExc_ValueError, "ndigits must be positive"); | ||
return NULL; | ||
goto error; | ||
} | ||
assert(digits != NULL); | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
PyLongObject *obj = _PyLong_New(ndigits); | ||
if (obj == NULL) { | ||
return NULL; | ||
goto error; | ||
} | ||
if (negative) { | ||
_PyLong_FlipSign(obj); | ||
} | ||
|
||
*digits = obj->long_value.ob_digit; | ||
return (PyLongWriter*)obj; | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
error: | ||
*digits = NULL; | ||
return NULL; | ||
} | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.