Skip to content

Commit 1ad88f5

Browse files
committed
Undo addition to PyConfig to ease backporting.
Release branches MUST NOT have `struct PyConfig` change. Doing it this way initially for 3.12 simplifies the backporting process. This commit is intended to be reverted in 3.12 after this lands in older releases.
1 parent 76ae1c2 commit 1ad88f5

File tree

7 files changed

+11
-26
lines changed

7 files changed

+11
-26
lines changed

Doc/c-api/init_config.rst

-12
Original file line numberDiff line numberDiff line change
@@ -828,18 +828,6 @@ PyConfig
828828
829829
Default: ``0``.
830830
831-
.. c:member:: int int_max_str_digits
832-
833-
If greater than 0, enable int conversion digit limitations. ``-1`` means
834-
that :data:`sys.int_info.default_max_str_digits` will be used.
835-
836-
Configured by the :option:`-X int_max_str_digits <-X>` command line
837-
flag or the :envvar:`PYTHONINTMAXSTRDIGITS` environment varable.
838-
839-
Default: ``-1``.
840-
841-
.. versionadded:: 3.12
842-
843831
.. c:member:: int isolated
844832
845833
If greater than ``0``, enable isolated mode:

Include/cpython/initconfig.h

-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ typedef struct PyConfig {
178178
wchar_t *check_hash_pycs_mode;
179179
int use_frozen_modules;
180180
int safe_path;
181-
int int_max_str_digits; // NOTE(gpshead): do not backport to stable releases due to struct change.
182181

183182
/* --- Path configuration inputs ------------ */
184183
int pathconfig_warnings;

Include/internal/pycore_initconfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ extern void _Py_DumpPathConfig(PyThreadState *tstate);
170170

171171
PyAPI_FUNC(PyObject*) _Py_Get_Getpath_CodeObject(void);
172172

173+
extern int _Py_global_config_int_max_str_digits; // TODO(gpshead): move this into PyConfig in 3.12 after the backports ship.
174+
173175

174176
/* --- Function used for testing ---------------------------------- */
175177

Lib/test/test_embed.py

-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
434434
'install_signal_handlers': 1,
435435
'use_hash_seed': 0,
436436
'hash_seed': 0,
437-
'int_max_str_digits': -1,
438437
'faulthandler': 0,
439438
'tracemalloc': 0,
440439
'perf_profiling': 0,

Objects/longobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6179,7 +6179,7 @@ _PyLong_InitTypes(PyInterpreterState *interp)
61796179
return _PyStatus_ERR("can't init int info type");
61806180
}
61816181
}
6182-
interp->int_max_str_digits = _PyInterpreterState_GetConfig(interp)->int_max_str_digits;
6182+
interp->int_max_str_digits = _Py_global_config_int_max_str_digits;
61836183
if (interp->int_max_str_digits == -1) {
61846184
interp->int_max_str_digits = _PY_LONG_DEFAULT_MAX_STR_DIGITS;
61856185
}

Python/initconfig.c

+7-10
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,12 @@ _PyConfig_InitCompatConfig(PyConfig *config)
791791
config->safe_path = 0;
792792
config->_is_python_build = 0;
793793
config->code_debug_ranges = 1;
794-
/* config_init_int_max_str_digits() sets default limit */
795-
config->int_max_str_digits = -1;
796794
}
797795

796+
/* Excluded from public struct PyConfig for backporting reasons. */
797+
/* default to unconfigured, _PyLong_InitTypes() does the rest */
798+
int _Py_global_config_int_max_str_digits = -1;
799+
798800

799801
static void
800802
config_init_defaults(PyConfig *config)
@@ -1019,7 +1021,6 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
10191021
COPY_ATTR(safe_path);
10201022
COPY_WSTRLIST(orig_argv);
10211023
COPY_ATTR(_is_python_build);
1022-
COPY_ATTR(int_max_str_digits);
10231024

10241025
#undef COPY_ATTR
10251026
#undef COPY_WSTR_ATTR
@@ -1127,7 +1128,6 @@ _PyConfig_AsDict(const PyConfig *config)
11271128
SET_ITEM_INT(use_frozen_modules);
11281129
SET_ITEM_INT(safe_path);
11291130
SET_ITEM_INT(_is_python_build);
1130-
SET_ITEM_INT(int_max_str_digits);
11311131

11321132
return dict;
11331133

@@ -1781,9 +1781,6 @@ config_init_int_max_str_digits(PyConfig *config)
17811781
int maxdigits;
17821782
int valid = 0;
17831783

1784-
/* default to unconfigured, _PyLong_InitTypes() does the rest */
1785-
config->int_max_str_digits = -1;
1786-
17871784
const char *env = config_get_env(config, "PYTHONINTMAXSTRDIGITS");
17881785
if (env) {
17891786
if (!_Py_str_to_int(env, &maxdigits)) {
@@ -1797,7 +1794,7 @@ config_init_int_max_str_digits(PyConfig *config)
17971794
STRINGIFY(_PY_LONG_MAX_STR_DIGITS_THRESHOLD)
17981795
" or 0 for unlimited.");
17991796
}
1800-
config->int_max_str_digits = maxdigits;
1797+
_Py_global_config_int_max_str_digits = maxdigits;
18011798
}
18021799

18031800
const wchar_t *xoption = config_get_xoption(config, L"int_max_str_digits");
@@ -1816,7 +1813,7 @@ config_init_int_max_str_digits(PyConfig *config)
18161813
#undef _STRINGIFY
18171814
#undef STRINGIFY
18181815
}
1819-
config->int_max_str_digits = maxdigits;
1816+
_Py_global_config_int_max_str_digits = maxdigits;
18201817
}
18211818
return _PyStatus_OK();
18221819
}
@@ -1884,7 +1881,7 @@ config_read_complex_options(PyConfig *config)
18841881
}
18851882
}
18861883

1887-
if (config->int_max_str_digits < 0) {
1884+
if (_Py_global_config_int_max_str_digits < 0) {
18881885
status = config_init_int_max_str_digits(config);
18891886
if (_PyStatus_EXCEPTION(status)) {
18901887
return status;

Python/sysmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ set_flags_from_config(PyInterpreterState *interp, PyObject *flags)
27772777
SetFlag(preconfig->utf8_mode);
27782778
SetFlag(config->warn_default_encoding);
27792779
SetFlagObj(PyBool_FromLong(config->safe_path));
2780-
SetFlag(config->int_max_str_digits);
2780+
SetFlag(_Py_global_config_int_max_str_digits);
27812781
#undef SetFlagObj
27822782
#undef SetFlag
27832783
return 0;

0 commit comments

Comments
 (0)