File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -550,18 +550,23 @@ def foo(a, b):
550550        co_framesize  =  _testinternalcapi .get_co_framesize (c )
551551        FRAME_SPECIALS_SIZE  =  co_framesize  -  c .co_stacksize  -  co_nlocalsplus 
552552
553-         ptr_sizeof  =  ctypes .sizeof (ctypes .c_void_p )  # sizeof(PyObject *) 
553+         ps  =  ctypes .sizeof (ctypes .c_void_p )  # sizeof(PyObject *) 
554+         smallest_evil_co_stacksize  =  (
555+             (_testcapi .INT_MAX  -  co_nlocalsplus  -  FRAME_SPECIALS_SIZE ) //  ps 
556+         )
554557
555558        for  evil_co_stacksize  in  [
556559            _testcapi .INT_MAX ,
557-             _testcapi .INT_MAX  //  ptr_sizeof ,
558-             ( _testcapi . INT_MAX   -   co_nlocalsplus   -   FRAME_SPECIALS_SIZE )  //   ptr_sizeof ,
560+             _testcapi .INT_MAX  //  ps ,
561+             smallest_evil_co_stacksize ,
559562        ]:
560563            with  (
561564                self .subTest (evil_co_stacksize ),
562565                self .assertRaisesRegex (OverflowError , "co_stacksize" )
563566            ):
564-                 foo .__code__ .__replace__ (co_stacksize = evil_co_stacksize )
567+                 c .__replace__ (co_stacksize = evil_co_stacksize )
568+ 
569+         c .__replace__ (co_stacksize = smallest_evil_co_stacksize  -  1 )
565570
566571
567572def  isinterned (s ):
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments