summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tkinter/test_misc.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-24 09:45:45 (GMT)
committerGitHub <noreply@github.com>2024-06-24 09:45:45 (GMT)
commit732c00550f20e73edeac03d9e222c4a719362649 (patch)
treee1465166ee1bc4eee3000901d6465083f7d1f7a3 /Lib/test/test_tkinter/test_misc.py
parent206028dba986f982a940377ab1cb8b8276301b82 (diff)
downloadcpython-732c00550f20e73edeac03d9e222c4a719362649.zip
cpython-732c00550f20e73edeac03d9e222c4a719362649.tar.gz
cpython-732c00550f20e73edeac03d9e222c4a719362649.tar.bz2
[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 c38e2f64d012929168dfef7363c9e48bd1a6c731) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_tkinter/test_misc.py')
-rw-r--r--Lib/test/test_tkinter/test_misc.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py
index d9ea642..b0b9ed6 100644
--- a/Lib/test/test_tkinter/test_misc.py
+++ b/Lib/test/test_tkinter/test_misc.py
@@ -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):