mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-98417: Store int_max_str_digits on the Interpreter State (GH-98418)
This commit is contained in:
parent
52fcba6512
commit
9c8dde0fa5
4 changed files with 13 additions and 5 deletions
|
@ -1767,7 +1767,7 @@ long_to_decimal_string_internal(PyObject *aa,
|
|||
if (size_a >= 10 * _PY_LONG_MAX_STR_DIGITS_THRESHOLD
|
||||
/ (3 * PyLong_SHIFT) + 2) {
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
int max_str_digits = interp->config.int_max_str_digits;
|
||||
int max_str_digits = interp->long_state.max_str_digits;
|
||||
if ((max_str_digits > 0) &&
|
||||
(max_str_digits / (3 * PyLong_SHIFT) <= (size_a - 11) / 10)) {
|
||||
PyErr_Format(PyExc_ValueError, _MAX_STR_DIGITS_ERROR_FMT_TO_STR,
|
||||
|
@ -1837,7 +1837,7 @@ long_to_decimal_string_internal(PyObject *aa,
|
|||
}
|
||||
if (strlen > _PY_LONG_MAX_STR_DIGITS_THRESHOLD) {
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
int max_str_digits = interp->config.int_max_str_digits;
|
||||
int max_str_digits = interp->long_state.max_str_digits;
|
||||
Py_ssize_t strlen_nosign = strlen - negative;
|
||||
if ((max_str_digits > 0) && (strlen_nosign > max_str_digits)) {
|
||||
Py_DECREF(scratch);
|
||||
|
@ -2578,7 +2578,7 @@ long_from_string_base(const char **str, int base, PyLongObject **res)
|
|||
* quadratic algorithm. */
|
||||
if (digits > _PY_LONG_MAX_STR_DIGITS_THRESHOLD) {
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
int max_str_digits = interp->config.int_max_str_digits;
|
||||
int max_str_digits = interp->long_state.max_str_digits;
|
||||
if ((max_str_digits > 0) && (digits > max_str_digits)) {
|
||||
PyErr_Format(PyExc_ValueError, _MAX_STR_DIGITS_ERROR_FMT_TO_INT,
|
||||
max_str_digits, digits);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue