8000 gh-96512: Move int_max_str_digits setting to PyConfig by gpshead · Pull Request #96944 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-96512: Move int_max_str_digits setting to PyConfig #96944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 3, 2022
Prev Previous commit
Next Next commit
Add a test_capi test to verify unique configs.
Also demonstrates that subinterpreters maintain their own limit
as a feature.
  • Loading branch information
gpshead committed Sep 20, 2022
commit 86c4b6e0222fbe0ac8c697fcdf55b388c632da86
24 changes: 24 additions & 0 deletions Lib/test/test_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,30 @@ async def foo(arg): return await arg # Py 3.5
self.assertEqual(ret, 0)
self.assertEqual(pickle.load(f), {'a': '123x', 'b': '123'})

def test_int_max_str_digits_config_is_per_interp(self):
code = """if 1:
import sys, _testinternalcapi

config = _testinternalcapi.get_config()
config['int_max_str_digits'] = 55555
_testinternalcapi.set_config(config)
sub_value = _testinternalcapi.get_config()['int_max_str_digits']
assert sub_value == 55555, sub_value
# Subinterpreters maintain and enforce their own limit
sys.set_int_max_str_digits(2323)
try:
int('3'*3333)
except ValueError:
pass
else:
raise AssertionError('Expected a int max str digits ValueError.')
"""
before_cfg_value = _testinternalcapi.get_config()['int_max_str_digits']
self.assertEqual(support.run_in_subinterp(code), 0,
'subinterp code failure, see stderr.')
after_cfg_value = _testinternalcapi.get_config()['int_max_str_digits']
self.assertEqual(before_cfg_value, after_cfg_value)

def test_mutate_exception(self):
"""
Exceptions saved in global module state get shared between
Expand Down
0