diff --git a/changelog/68775.fixed.md b/changelog/68775.fixed.md new file mode 100644 index 000000000000..fbd29bee257e --- /dev/null +++ b/changelog/68775.fixed.md @@ -0,0 +1 @@ +Remove the integer-to-string conversion limit for `test.fib` function. diff --git a/salt/modules/test.py b/salt/modules/test.py index 3cd9d7d5ea43..2c5a236e1747 100644 --- a/salt/modules/test.py +++ b/salt/modules/test.py @@ -346,6 +346,12 @@ def fib(num): salt '*' test.fib 3 """ + # Remove the limit on the number of digits in an int, + # as Fibonacci numbers grow very quickly. + # The default limit for integer string conversion is 4300 digits, + # which means that num > 20577 will fail with a ValueError. + sys.set_int_max_str_digits(0) + num = int(num) if num < 0: raise ValueError("Negative number is not allowed!") diff --git a/tests/pytests/integration/cli/test_salt_call.py b/tests/pytests/integration/cli/test_salt_call.py index f927f499c858..5df8b87be1ad 100644 --- a/tests/pytests/integration/cli/test_salt_call.py +++ b/tests/pytests/integration/cli/test_salt_call.py @@ -34,6 +34,11 @@ def test_fib(salt_call_cli): assert ret.data[0] == 2 +def test_fib_str_limit(salt_call_cli): + ret = salt_call_cli.run("test.fib", "20578") + assert ret.returncode == 0 + + def test_fib_txt_output(salt_call_cli): ret = salt_call_cli.run("--output=txt", "test.fib", "3") assert ret.returncode == 0