Skip to content

Commit 6bf8c69

Browse files
Merge branch '3.14' into backport-f252132-3.14
2 parents 6edaa9f + 4d63459 commit 6bf8c69

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_kill_issue43884(self):
219219
# kills the process and all its children.
220220
creationflags = CREATE_NEW_PROCESS_GROUP
221221
proc = self.loop.run_until_complete(
222-
asyncio.create_subprocess_shell(blocking_shell_command, stdout=asyncio.subprocess.PIPE,
222+
asyncio.create_subprocess_shell(blocking_shell_command,
223223
creationflags=creationflags)
224224
)
225225
self.loop.run_until_complete(asyncio.sleep(1))

Lib/test/test_curses.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,10 @@ def test_output_character(self):
326326
stdscr.move(2, 0)
327327
stdscr.echochar(v)
328328
self.assertEqual(self._read_char(2, 0), c)
329-
# insch() round-trips a byte only where its code point equals
330-
# the byte value (Latin-1): on a wide build ncurses winsch
331-
# stores a printable byte directly as a code point instead of
332-
# decoding it through the locale.
333-
if ord(c) < 0x100:
334-
stdscr.insch(1, 0, v)
335-
self.assertEqual(self._read_char(1, 0), c)
329+
# insch() decodes the byte through the locale like addch(), so
330+
# it round-trips the same character.
331+
stdscr.insch(1, 0, v)
332+
self.assertEqual(self._read_char(1, 0), c)
336333

337334
# The same characters supplied as a str. Unlike the int path above, a
338335
# str is stored as a wide-character cell on a wide build, so every
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
On a wide :mod:`curses` build, :meth:`curses.window.insch` now inserts a
2+
non-ASCII byte as the character it encodes in the window's encoding,
3+
consistently with :meth:`~curses.window.addch`, instead of its code point.

Modules/_cursesmodule.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,27 @@ _curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1,
18711871
if (!PyCurses_ConvertToChtype(self, ch, &ch_))
18721872
return NULL;
18731873

1874+
#ifdef HAVE_NCURSESW
1875+
/* winsch() does not locale-decode a byte above 127 on a wide build,
1876+
unlike waddch(), so decode it here and insert it as a wide character. */
1877+
chtype cch = ch_ & A_CHARTEXT;
1878+
if (cch > 127) {
1879+
wint_t wc = btowc((int)cch);
1880+
if (wc != WEOF) {
1881+
cchar_t wch;
1882+
wchar_t wstr[2] = { (wchar_t)wc, L'\0' };
1883+
attr_t cattr = (attr_t)((ch_ | (attr_t)attr) & ~(chtype)A_CHARTEXT);
1884+
setcchar(&wch, wstr, cattr, PAIR_NUMBER(cattr), NULL);
1885+
if (!group_left_1) {
1886+
rtn = wins_wch(self->win, &wch);
1887+
}
1888+
else {
1889+
rtn = mvwins_wch(self->win, y, x, &wch);
1890+
}
1891+
return PyCursesCheckERR_ForWin(self, rtn, "insch");
1892+
}
1893+
}
1894+
#endif
18741895
if (!group_left_1) {
18751896
rtn = winsch(self->win, ch_ | (attr_t)attr);
18761897
}

0 commit comments

Comments
 (0)