mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	[3.13] gh-127196: Fix crash in _interpreters, when shared had invalid encodings (GH-127220) (#128689)
				
					
				
			gh-127196: Fix crash in `_interpreters`, when `shared` had invalid encodings (GH-127220)
(cherry picked from commit 087bb48aca)
Co-authored-by: sobolevn <mail@sobolevn.me>
			
			
This commit is contained in:
		
							parent
							
								
									c57ef49337
								
							
						
					
					
						commit
						0d2b9abd18
					
				
					 3 changed files with 20 additions and 2 deletions
				
			
		|  | @ -557,7 +557,7 @@ def setUp(self): | |||
|         self.id = _interpreters.create() | ||||
| 
 | ||||
|     def test_signatures(self): | ||||
|         # for method in ['exec', 'run_string', 'run_func']: | ||||
|         # See https://github.com/python/cpython/issues/126654 | ||||
|         msg = "expected 'shared' to be a dict" | ||||
|         with self.assertRaisesRegex(TypeError, msg): | ||||
|             _interpreters.exec(self.id, 'a', 1) | ||||
|  | @ -568,6 +568,17 @@ def test_signatures(self): | |||
|         with self.assertRaisesRegex(TypeError, msg): | ||||
|             _interpreters.run_func(self.id, lambda: None, shared=1) | ||||
| 
 | ||||
|     def test_invalid_shared_encoding(self): | ||||
|         # See https://github.com/python/cpython/issues/127196 | ||||
|         bad_shared = {"\uD82A": 0} | ||||
|         msg = 'surrogates not allowed' | ||||
|         with self.assertRaisesRegex(UnicodeEncodeError, msg): | ||||
|             _interpreters.exec(self.id, 'a', shared=bad_shared) | ||||
|         with self.assertRaisesRegex(UnicodeEncodeError, msg): | ||||
|             _interpreters.run_string(self.id, 'a', shared=bad_shared) | ||||
|         with self.assertRaisesRegex(UnicodeEncodeError, msg): | ||||
|             _interpreters.run_func(self.id, lambda: None, shared=bad_shared) | ||||
| 
 | ||||
| 
 | ||||
| class RunStringTests(TestBase): | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)