mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-119614: Fix truncation of strings with embedded null characters in Tkinter (GH-120909)
Now the null character is always represented as \xc0\x80 for Tcl_NewStringObj().
This commit is contained in:
parent
fc297b4ba4
commit
c38e2f64d0
4 changed files with 68 additions and 7 deletions
|
@ -476,6 +476,15 @@ class MiscTest(AbstractTkTest, unittest.TestCase):
|
|||
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