File tree Expand file tree Collapse file tree 5 files changed +35
-11
lines changed
Expand file tree Collapse file tree 5 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ jobs:
245245 - uses : dtolnay/rust-toolchain@stable
246246 - uses : actions/setup-python@v4
247247 with :
248- python-version : " 3.11"
248+ python-version : " 3.11.4 "
249249 - name : Set up the Windows environment
250250 shell : bash
251251 run : |
Original file line number Diff line number Diff line change @@ -92,3 +92,17 @@ def recursive_call(n):
9292 # assert winver.major == winver.platform_version[0]
9393 # assert winver.minor == winver.platform_version[1]
9494 # assert winver.build == winver.platform_version[2]
95+
96+ # test int_max_str_digits getter and setter
97+
98+ assert sys .get_int_max_str_digits () == 4300
99+ sys .set_int_max_str_digits (640 )
100+ assert sys .get_int_max_str_digits () == 640
101+ sys .set_int_max_str_digits (0 )
102+ assert sys .get_int_max_str_digits () == 0
103+
104+ with assert_raises (ValueError ):
105+ sys .set_int_max_str_digits (1 )
106+
107+ sys .set_int_max_str_digits (1000 )
108+ assert sys .get_int_max_str_digits () == 1000
Original file line number Diff line number Diff line change 11import os
2- import platform
32
43from testutils import assert_raises
54
65dir_path = os .path .dirname (os .path .realpath (__file__ ))
76
8- # TODO: RUSTPYTHON. At some point snippets will fail and it will look confusing
9- # and out of the blue. This is going to be the cause and it's going to happen when
10- # the github worker for MacOS starts using Python 3.11.4.
11- if platform .python_implementation () == "CPython" and platform .system () == 'Darwin' :
12- expectedException = ValueError
13- else :
14- expectedException = SyntaxError
15-
16- with assert_raises (expectedException ):
7+ with assert_raises (SyntaxError ):
178 with open (os .path .join (dir_path , "non_utf8.txt" )) as f :
189 eval (f .read ())
Original file line number Diff line number Diff line change @@ -616,6 +616,23 @@ mod sys {
616616 PyIntInfo :: INFO . into_struct_sequence ( vm)
617617 }
618618
619+ #[ pyfunction]
620+ fn get_int_max_str_digits ( vm : & VirtualMachine ) -> usize {
621+ vm. state . int_max_str_digits . load ( )
622+ }
623+
624+ #[ pyfunction]
625+ fn set_int_max_str_digits ( maxdigits : usize , vm : & VirtualMachine ) -> PyResult < ( ) > {
626+ let threshold = PyIntInfo :: INFO . str_digits_check_threshold ;
627+ if maxdigits == 0 || maxdigits >= threshold {
628+ vm. state . int_max_str_digits . store ( maxdigits) ;
629+ Ok ( ( ) )
630+ } else {
631+ let error = format ! ( "maxdigits must be 0 or larger than {:?}" , threshold) ;
632+ Err ( vm. new_value_error ( error) )
633+ }
634+ }
635+
619636 #[ pyfunction]
620637 fn is_finalizing ( vm : & VirtualMachine ) -> bool {
621638 vm. state . finalizing . load ( Ordering :: Acquire )
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ pub struct PyGlobalState {
100100 pub before_forkers : PyMutex < Vec < PyObjectRef > > ,
101101 pub after_forkers_child : PyMutex < Vec < PyObjectRef > > ,
102102 pub after_forkers_parent : PyMutex < Vec < PyObjectRef > > ,
103+ pub int_max_str_digits : AtomicCell < usize > ,
103104}
104105
105106pub fn process_hash_secret_seed ( ) -> u32 {
@@ -180,6 +181,7 @@ impl VirtualMachine {
180181 before_forkers : PyMutex :: default ( ) ,
181182 after_forkers_child : PyMutex :: default ( ) ,
182183 after_forkers_parent : PyMutex :: default ( ) ,
184+ int_max_str_digits : AtomicCell :: new ( 4300 ) ,
183185 } ) ,
184186 initialized : false ,
185187 recursion_depth : Cell :: new ( 0 ) ,
You can’t perform that action at this time.
0 commit comments