Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df5bccc

Browse files
author
Victor Stinner
committed
(Merge 3.2) Issue #10570: curses.tigetstr() is now expecting a byte string,
instead of a Unicode string. This is an incompatible change, but the previous behaviour was completly wrong.
2 parents 2787ea4 + 2662133 commit df5bccc

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

Doc/library/curses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ The module :mod:`curses` defines the following functions:
566566

567567
Instantiate the string *str* with the supplied parameters, where *str* should
568568
be a parameterized string obtained from the terminfo database. E.g.
569-
``tparm(tigetstr("cup"), 5, 3)`` could result in ``'\033[6;4H'``, the exact
569+
``tparm(tigetstr("cup"), 5, 3)`` could result in ``b'\033[6;4H'``, the exact
570570
result depending on terminal type.
571571

572572

Lib/test/test_curses.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def module_funcs(stdscr):
190190
curses.tigetflag('hc')
191191
curses.tigetnum('co')
192192
curses.tigetstr('cr')
193-
curses.tparm('cr')
193+
curses.tparm(b'cr')
194194
curses.typeahead(sys.__stdin__.fileno())
195195
curses.unctrl('a')
196196
curses.ungetch('a')
@@ -280,6 +280,10 @@ def test_unget_wch(stdscr):
280280
if read != ch:
281281
raise AssertionError("%r != %r" % (read, ch))
282282

283+
def test_issue10570():
284+
b = curses.tparm(curses.tigetstr("cup"), 5, 3)
285+
assert type(b) is bytes
286+
283287
def main(stdscr):
284288
curses.savetty()
285289
try:
@@ -289,6 +293,7 @@ def main(stdscr):
289293
test_resize_term(stdscr)
290294
test_issue6243(stdscr)
291295
test_unget_wch(stdscr)
296+
test_issue10570()
292297
finally:
293298
curses.resetty()
294299

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ Core and Builtins
350350
Library
351351
-------
352352

353+
- Issue #10570: curses.tigetstr() is now expecting a byte string, instead of
354+
a Unicode string.
355+
353356
- Issue #13295: http.server now produces valid HTML 4.01 strict.
354357

355358
- Issue #2892: preserve iterparse events in case of SyntaxError.

Modules/_cursesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,7 +2642,7 @@ PyCurses_tparm(PyObject *self, PyObject *args)
26422642

26432643
PyCursesSetupTermCalled;
26442644

2645-
if (!PyArg_ParseTuple(args, "s|iiiiiiiii:tparm",
2645+
if (!PyArg_ParseTuple(args, "y|iiiiiiiii:tparm",
26462646
&fmt, &i1, &i2, &i3, &i4,
26472647
&i5, &i6, &i7, &i8, &i9)) {
26482648
return NULL;

0 commit comments

Comments
 (0)