mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	GH-101578: Normalize the current exception (GH-101607)
* Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
This commit is contained in:
		
							parent
							
								
									027adf42cd
								
							
						
					
					
						commit
						feec49c407
					
				
					 29 changed files with 477 additions and 172 deletions
				
			
		| 
						 | 
				
			
			@ -347,6 +347,7 @@ def test_capi2():
 | 
			
		|||
                _testcapi.raise_exception(BadException, 0)
 | 
			
		||||
            except RuntimeError as err:
 | 
			
		||||
                exc, err, tb = sys.exc_info()
 | 
			
		||||
                tb = tb.tb_next
 | 
			
		||||
                co = tb.tb_frame.f_code
 | 
			
		||||
                self.assertEqual(co.co_name, "__init__")
 | 
			
		||||
                self.assertTrue(co.co_filename.endswith('test_exceptions.py'))
 | 
			
		||||
| 
						 | 
				
			
			@ -1415,8 +1416,8 @@ def gen():
 | 
			
		|||
    @cpython_only
 | 
			
		||||
    def test_recursion_normalizing_infinite_exception(self):
 | 
			
		||||
        # Issue #30697. Test that a RecursionError is raised when
 | 
			
		||||
        # PyErr_NormalizeException() maximum recursion depth has been
 | 
			
		||||
        # exceeded.
 | 
			
		||||
        # maximum recursion depth has been exceeded when creating
 | 
			
		||||
        # an exception
 | 
			
		||||
        code = """if 1:
 | 
			
		||||
            import _testcapi
 | 
			
		||||
            try:
 | 
			
		||||
| 
						 | 
				
			
			@ -1426,8 +1427,7 @@ def test_recursion_normalizing_infinite_exception(self):
 | 
			
		|||
        """
 | 
			
		||||
        rc, out, err = script_helper.assert_python_failure("-c", code)
 | 
			
		||||
        self.assertEqual(rc, 1)
 | 
			
		||||
        self.assertIn(b'RecursionError: maximum recursion depth exceeded '
 | 
			
		||||
                      b'while normalizing an exception', err)
 | 
			
		||||
        self.assertIn(b'RecursionError: maximum recursion depth exceeded', err)
 | 
			
		||||
        self.assertIn(b'Done.', out)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue