GitHub

File tree

  • Lib/test

  • Misc/NEWS.d/next/Core and Builtins

  • Python

Original file line numberDiff line numberDiff line change

@@ -874,6 +874,8 @@ def test_int_max_str_digits(self):

874874

assert_python_failure('-X', 'int_max_str_digits', '-c', code)

875875

assert_python_failure('-X', 'int_max_str_digits=foo', '-c', code)

876876

assert_python_failure('-X', 'int_max_str_digits=100', '-c', code)

877+

assert_python_failure('-X', 'int_max_str_digits', '-c', code,

878+

PYTHONINTMAXSTRDIGITS='4000')

877879
878880

assert_python_failure('-c', code, PYTHONINTMAXSTRDIGITS='foo')

879881

assert_python_failure('-c', code, PYTHONINTMAXSTRDIGITS='100')

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,3 @@

1+

Fix command line parsing: reject :option:`-X int_max_str_digits <-X>` option

2+

with no value (invalid) when the :envvar:`PYTHONINTMAXSTRDIGITS` environment

3+

variable is set to a valid limit. Patch by Victor Stinner.

Original file line numberDiff line numberDiff line change

@@ -1734,10 +1734,10 @@ static PyStatus

17341734

config_init_int_max_str_digits(PyConfig *config)

17351735

{

17361736

int maxdigits;

1737-

int valid = 0;

17381737
17391738

const char *env = config_get_env(config, "PYTHONINTMAXSTRDIGITS");

17401739

if (env) {

1740+

int valid = 0;

17411741

if (!_Py_str_to_int(env, &maxdigits)) {

17421742

valid = ((maxdigits == 0) || (maxdigits >= _PY_LONG_MAX_STR_DIGITS_THRESHOLD));

17431743

}

@@ -1755,6 +1755,7 @@ config_init_int_max_str_digits(PyConfig *config)

17551755

const wchar_t *xoption = config_get_xoption(config, L"int_max_str_digits");

17561756

if (xoption) {

17571757

const wchar_t *sep = wcschr(xoption, L'=');

1758+

int valid = 0;

17581759

if (sep) {

17591760

if (!config_wstr_to_int(sep + 1, &maxdigits)) {

17601761

valid = ((maxdigits == 0) || (maxdigits >= _PY_LONG_MAX_STR_DIGITS_THRESHOLD));

Read the original on github.com ↗