diff options
author | Victor Stinner <vstinner@python.org> | 2022-09-26 15:20:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-26 15:20:08 (GMT) |
commit | 41351662bcd21672d8ccfa62fe44d72027e6bcf8 (patch) | |
tree | 97bede41a5c3871f7601794079311892137613c9 /Python | |
parent | 2b428a1faed88f148ede131e3b86ab6227c6c3f0 (diff) | |
download | cpython-41351662bcd21672d8ccfa62fe44d72027e6bcf8.zip cpython-41351662bcd21672d8ccfa62fe44d72027e6bcf8.tar.gz cpython-41351662bcd21672d8ccfa62fe44d72027e6bcf8.tar.bz2 |
gh-96848: Fix -X int_max_str_digits option parsing (#96988)
Fix command line parsing: reject "-X int_max_str_digits" option with
no value (invalid) when the PYTHONINTMAXSTRDIGITS environment
variable is set to a valid limit.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/initconfig.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/initconfig.c b/Python/initconfig.c index f18ec40..bfbb7db 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -1779,10 +1779,10 @@ static PyStatus config_init_int_max_str_digits(PyConfig *config) { int maxdigits; - int valid = 0; const char *env = config_get_env(config, "PYTHONINTMAXSTRDIGITS"); if (env) { + int valid = 0; if (!_Py_str_to_int(env, &maxdigits)) { valid = ((maxdigits == 0) || (maxdigits >= _PY_LONG_MAX_STR_DIGITS_THRESHOLD)); } @@ -1800,6 +1800,7 @@ config_init_int_max_str_digits(PyConfig *config) const wchar_t *xoption = config_get_xoption(config, L"int_max_str_digits"); if (xoption) { const wchar_t *sep = wcschr(xoption, L'='); + int valid = 0; if (sep) { if (!config_wstr_to_int(sep + 1, &maxdigits)) { valid = ((maxdigits == 0) || (maxdigits >= _PY_LONG_MAX_STR_DIGITS_THRESHOLD)); |