mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	[3.13] gh-119614: Fix truncation of strings with embedded null characters in Tkinter (GH-120909) (GH-120938)
Now the null character is always represented as \xc0\x80 for
Tcl_NewStringObj().
(cherry picked from commit c38e2f64d0)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									206028dba9
								
							
						
					
					
						commit
						732c00550f
					
				
					 4 changed files with 68 additions and 7 deletions
				
			
		|  | @ -476,6 +476,15 @@ def test_info_patchlevel(self): | |||
|             self.assertEqual(vi.micro, 0) | ||||
|         self.assertTrue(str(vi).startswith(f'{vi.major}.{vi.minor}')) | ||||
| 
 | ||||
|     def test_embedded_null(self): | ||||
|         widget = tkinter.Entry(self.root) | ||||
|         widget.insert(0, 'abc\0def')  # ASCII-only | ||||
|         widget.selection_range(0, 'end') | ||||
|         self.assertEqual(widget.selection_get(), 'abc\x00def') | ||||
|         widget.insert(0, '\u20ac\0')  # non-ASCII | ||||
|         widget.selection_range(0, 'end') | ||||
|         self.assertEqual(widget.selection_get(), '\u20ac\0abc\x00def') | ||||
| 
 | ||||
| 
 | ||||
| class WmTest(AbstractTkTest, unittest.TestCase): | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)