Add get_int_max_str_digits and set_int_max_str_digits in sys. (#5014)

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
This commit is contained in:
Dan Näsman
2023-06-17 22:46:22 +02:00
committed by GitHub
parent 3d2c51962b
commit 1cdc5d3294
5 changed files with 35 additions and 11 deletions

View File

@@ -92,3 +92,17 @@ if sys.platform.startswith("win"):
# assert winver.major == winver.platform_version[0]
# assert winver.minor == winver.platform_version[1]
# assert winver.build == winver.platform_version[2]
# test int_max_str_digits getter and setter
assert sys.get_int_max_str_digits() == 4300
sys.set_int_max_str_digits(640)
assert sys.get_int_max_str_digits() == 640
sys.set_int_max_str_digits(0)
assert sys.get_int_max_str_digits() == 0
with assert_raises(ValueError):
sys.set_int_max_str_digits(1)
sys.set_int_max_str_digits(1000)
assert sys.get_int_max_str_digits() == 1000

View File

@@ -1,18 +1,9 @@
import os
import platform
from testutils import assert_raises
dir_path = os.path.dirname(os.path.realpath(__file__))
# TODO: RUSTPYTHON. At some point snippets will fail and it will look confusing
# and out of the blue. This is going to be the cause and it's going to happen when
# the github worker for MacOS starts using Python 3.11.4.
if platform.python_implementation() == "CPython" and platform.system() == 'Darwin':
expectedException = ValueError
else:
expectedException = SyntaxError
with assert_raises(expectedException):
with assert_raises(SyntaxError):
with open(os.path.join(dir_path , "non_utf8.txt")) as f:
eval(f.read())