Skip to content

Commit d9c97fc

Browse files
gh-133031: Fix test_textbox_edit_wide on a narrow build
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 <noreply@anthropic.com>
1 parent bc08413 commit d9c97fc

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

Lib/test/test_curses.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,15 +2366,19 @@ def test_textbox_combining(self):
23662366
self.assertEqual(box.gather(), text + ' ')
23672367

23682368
def test_textbox_edit_wide(self):
2369-
# edit() reads characters through get_wch(). Each is used only if
2370-
# encodable in the current locale.
2369+
# edit() reads characters through get_wch(). Each character is pushed
2370+
# with unget_wch(), which on a narrow build requires it to encode to a
2371+
# single byte, so a non-ASCII case needs a wide build or an 8-bit locale.
23712372
for ch in ['A', 'é', '¤', '€', 'д']:
2372-
if self._encodable(ch):
2373-
with self.subTest(ch=ch):
2374-
box, win = self._make_textbox(1, 10)
2375-
for c in reversed(['a', ch, chr(curses.ascii.BEL)]):
2376-
curses.unget_wch(c)
2377-
self.assertEqual(box.edit(), 'a' + ch + ' ')
2373+
if not self._encodable(ch):
2374+
continue
2375+
if not WIDE_BUILD and len(ch.encode(self.stdscr.encoding)) != 1:
2376+
continue
2377+
with self.subTest(ch=ch):
2378+
box, win = self._make_textbox(1, 10)
2379+
for c in reversed(['a', ch, chr(curses.ascii.BEL)]):
2380+
curses.unget_wch(c)
2381+
self.assertEqual(box.edit(), 'a' + ch + ' ')
23782382

23792383
def test_textbox_movement(self):
23802384
box, win = self._make_textbox(3, 10)

0 commit comments

Comments
 (0)