mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
gh-96512: Move int_max_str_digits setting to PyConfig (#96944)
It had to live as a global outside of PyConfig for stable ABI reasons in the pre-3.12 backports. This removes the `_Py_global_config_int_max_str_digits` and gets rid of the equivalent field in the internal `struct _is PyInterpreterState` as code can just use the existing nested config struct within that. Adds tests to verify unique settings and configs in subinterpreters.
This commit is contained in:
parent
cfbc7dd910
commit
b0f89cb431
13 changed files with 111 additions and 24 deletions
|
@ -1717,7 +1717,7 @@ sys_get_int_max_str_digits_impl(PyObject *module)
|
|||
/*[clinic end generated code: output=0042f5e8ae0e8631 input=8dab13e2023e60d5]*/
|
||||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
return PyLong_FromSsize_t(interp->int_max_str_digits);
|
||||
return PyLong_FromLong(interp->config.int_max_str_digits);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
@ -1734,7 +1734,7 @@ sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits)
|
|||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
if ((!maxdigits) || (maxdigits >= _PY_LONG_MAX_STR_DIGITS_THRESHOLD)) {
|
||||
tstate->interp->int_max_str_digits = maxdigits;
|
||||
tstate->interp->config.int_max_str_digits = maxdigits;
|
||||
Py_RETURN_NONE;
|
||||
} else {
|
||||
PyErr_Format(
|
||||
|
@ -2810,7 +2810,7 @@ set_flags_from_config(PyInterpreterState *interp, PyObject *flags)
|
|||
SetFlag(preconfig->utf8_mode);
|
||||
SetFlag(config->warn_default_encoding);
|
||||
SetFlagObj(PyBool_FromLong(config->safe_path));
|
||||
SetFlag(_Py_global_config_int_max_str_digits);
|
||||
SetFlag(config->int_max_str_digits);
|
||||
#undef SetFlagObj
|
||||
#undef SetFlag
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue