File tree Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 3030import  weakref 
3131import  inspect 
3232import  sys 
33+ import  unittest 
3334
3435
3536try :
@@ -6247,23 +6248,27 @@ def f():
62476248        expected  =  "The source is: <<<def f():\n     print(0)\n     return 1 + 2\n >>>" 
62486249        self .assertIn (expected , output )
62496250
6250- 
6251- 
6252- 
6253- if  __name__  ==  "__main__" :
6254-     unittest .main ()
6255- 
6256- def  test_getframeinfo_with_exceptiongroup ():
6257-     code  =  """ 
6251+ class  TestInspect (unittest .TestCase ):
6252+     def  test_getframeinfo_with_exceptiongroup (self ):
6253+         code  =  """ 
62586254try: 
62596255    1/0 
62606256except* Exception: 
62616257    raise 
62626258""" 
6263-     try :
6264-         exec (code )
6265-     except :
6266-         tb  =  sys .exc_info ()[2 ]
6267-         while  tb :
6268-             info  =  inspect .getframeinfo (tb .tb_frame )
6269-             tb  =  tb .tb_next 
6259+         with  self .assertRaises (TypeError ):  # expect the bug to raise TypeError 
6260+             try :
6261+                 exec (code )
6262+             except :
6263+                 tb  =  sys .exc_info ()[2 ]
6264+                 while  tb :
6265+                     info  =  inspect .getframeinfo (tb .tb_frame )
6266+                     tb  =  tb .tb_next 
6267+ 
6268+ if  __name__  ==  "__main__" :
6269+     unittest .main ()
6270+ 
6271+ 
6272+ 
6273+ if  __name__  ==  "__main__" :
6274+     unittest .main ()
Original file line number Diff line number Diff line change 1+ bpo-139531: Fixed TypeError in inspect.getframeinfo when lineno is None in exception groups.
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments