mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-128863: Deprecate _PyLong_FromDigits() function (#127939)
This commit is contained in:
parent
3d8fc8b9ae
commit
233fd00f0a
5 changed files with 22 additions and 6 deletions
|
@ -205,7 +205,6 @@ _PyLong_FromDigits(int negative, Py_ssize_t digit_count, digit *digits)
|
|||
}
|
||||
PyLongObject *result = long_alloc(digit_count);
|
||||
if (result == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
_PyLong_SetSignAndDigitCount(result, negative?-1:1, digit_count);
|
||||
|
@ -217,15 +216,29 @@ PyObject *
|
|||
_PyLong_Copy(PyLongObject *src)
|
||||
{
|
||||
assert(src != NULL);
|
||||
int sign;
|
||||
|
||||
if (_PyLong_IsCompact(src)) {
|
||||
stwodigits ival = medium_value(src);
|
||||
if (IS_SMALL_INT(ival)) {
|
||||
return get_small_int((sdigit)ival);
|
||||
}
|
||||
sign = _PyLong_CompactSign(src);
|
||||
}
|
||||
else {
|
||||
sign = _PyLong_NonCompactSign(src);
|
||||
}
|
||||
|
||||
Py_ssize_t size = _PyLong_DigitCount(src);
|
||||
return (PyObject *)_PyLong_FromDigits(_PyLong_IsNegative(src), size, src->long_value.ob_digit);
|
||||
PyLongObject *result = long_alloc(size);
|
||||
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
_PyLong_SetSignAndDigitCount(result, sign, size);
|
||||
memcpy(result->long_value.ob_digit, src->long_value.ob_digit,
|
||||
size * sizeof(digit));
|
||||
return (PyObject *)result;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue