mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	[3.13] gh-125666: Avoid PyREPL exiting when a null byte is in input (GH-125732) (#126023)
gh-125666: Avoid PyREPL exiting when a null byte is in input (GH-125732)
(cherry picked from commit 44becb8cba)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
			
			
This commit is contained in:
		
							parent
							
								
									b1051577de
								
							
						
					
					
						commit
						fd48d98df9
					
				
					 4 changed files with 17 additions and 1 deletions
				
			
		|  | @ -117,6 +117,15 @@ def test_runsource_shows_syntax_error_for_failed_compilation(self): | |||
|             console.runsource(source) | ||||
|             mock_showsyntaxerror.assert_called_once() | ||||
| 
 | ||||
|     def test_runsource_survives_null_bytes(self): | ||||
|         console = InteractiveColoredConsole() | ||||
|         source = "\x00\n" | ||||
|         f = io.StringIO() | ||||
|         with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f): | ||||
|             result = console.runsource(source) | ||||
|         self.assertFalse(result) | ||||
|         self.assertIn("source code string cannot contain null bytes", f.getvalue()) | ||||
| 
 | ||||
|     def test_no_active_future(self): | ||||
|         console = InteractiveColoredConsole() | ||||
|         source = dedent("""\ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)