https://github.com/python/cpython/commit/b8cb0555d80bdb7a4d7a858d41402133a4d8ae9a
commit: b8cb0555d80bdb7a4d7a858d41402133a4d8ae9a
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-06-29T14:00:21Z
summary:

gh-133031: Fix test_textbox_edit_wide on a narrow build (GH-152592)

unget_wch() can push only a single-byte character on a narrow build,
so skip the multi-byte cases there.

Co-authored-by: Claude Opus 4.8 <[email protected]>

files:
M Lib/test/test_curses.py

diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index c79801aae4699b..17b31e4c7c8063 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -2366,15 +2366,19 @@ def test_textbox_combining(self):
             self.assertEqual(box.gather(), text + ' ')
 
     def test_textbox_edit_wide(self):
-        # edit() reads characters through get_wch().  Each is used only if
-        # encodable in the current locale.
+        # edit() reads characters through get_wch().  Each character is pushed
+        # with unget_wch(), which on a narrow build requires it to encode to a
+        # single byte, so a non-ASCII case needs a wide build or an 8-bit 
locale.
         for ch in ['A', 'é', '¤', '€', 'д']:
-            if self._encodable(ch):
-                with self.subTest(ch=ch):
-                    box, win = self._make_textbox(1, 10)
-                    for c in reversed(['a', ch, chr(curses.ascii.BEL)]):
-                        curses.unget_wch(c)
-                    self.assertEqual(box.edit(), 'a' + ch + ' ')
+            if not self._encodable(ch):
+                continue
+            if not WIDE_BUILD and len(ch.encode(self.stdscr.encoding)) != 1:
+                continue
+            with self.subTest(ch=ch):
+                box, win = self._make_textbox(1, 10)
+                for c in reversed(['a', ch, chr(curses.ascii.BEL)]):
+                    curses.unget_wch(c)
+                self.assertEqual(box.edit(), 'a' + ch + ' ')
 
     def test_textbox_movement(self):
         box, win = self._make_textbox(3, 10)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to