]> granicus.if.org Git - python/commitdiff
Issue #10570: curses.tigetstr() is now expecting a byte string, instead of a
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 2 Nov 2011 22:45:29 +0000 (23:45 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 2 Nov 2011 22:45:29 +0000 (23:45 +0100)
Unicode string.

This is an incompatible change, but the previous behaviour was completly wrong.

Doc/library/curses.rst
Lib/test/test_curses.py
Misc/NEWS
Modules/_cursesmodule.c

index 5470a10833699a34a40027b2554b537b07c798b7..f31b9c536b3409dba634fce7e0d14066776ac201 100644 (file)
@@ -566,7 +566,7 @@ The module :mod:`curses` defines the following functions:
 
    Instantiate the string *str* with the supplied parameters, where *str* should
    be a parameterized string obtained from the terminfo database.  E.g.
-   ``tparm(tigetstr("cup"), 5, 3)`` could result in ``'\033[6;4H'``, the exact
+   ``tparm(tigetstr("cup"), 5, 3)`` could result in ``b'\033[6;4H'``, the exact
    result depending on terminal type.
 
 
index b9ff34644b6b2cfb191f290c07d4c7b6d4d055d2..09807834b47c75c30646556951eef67bee126436 100644 (file)
@@ -190,7 +190,7 @@ def module_funcs(stdscr):
     curses.tigetflag('hc')
     curses.tigetnum('co')
     curses.tigetstr('cr')
-    curses.tparm('cr')
+    curses.tparm(b'cr')
     curses.typeahead(sys.__stdin__.fileno())
     curses.unctrl('a')
     curses.ungetch('a')
@@ -264,6 +264,10 @@ def test_issue6243(stdscr):
     curses.ungetch(1025)
     stdscr.getkey()
 
+def test_issue10570():
+    b = curses.tparm(curses.tigetstr("cup"), 5, 3)
+    assert type(b) is bytes
+
 def main(stdscr):
     curses.savetty()
     try:
@@ -272,6 +276,7 @@ def main(stdscr):
         test_userptr_without_set(stdscr)
         test_resize_term(stdscr)
         test_issue6243(stdscr)
+        test_issue10570()
     finally:
         curses.resetty()
 
index 9e7a96cc2f2d7ef85b92edda6ec4b6eb96eb8f36..993dfaec45cdcb44dbb55558ee5808ca8cd24cc5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #10570: curses.tigetstr() is now expecting a byte string, instead of
+  a Unicode string.
+
 - Issue #2892: preserve iterparse events in case of SyntaxError.
 
 - Issue #670664: Fix HTMLParser to correctly handle the content of
index 092fb69fb2827e30eea1821319761bf36d7f7032..4f7a5258cf57a9d19a2c0cde7d2c4e801c023b29 100644 (file)
@@ -2600,7 +2600,7 @@ PyCurses_tparm(PyObject *self, PyObject *args)
 
     PyCursesSetupTermCalled;
 
-    if (!PyArg_ParseTuple(args, "s|iiiiiiiii:tparm",
+    if (!PyArg_ParseTuple(args, "y|iiiiiiiii:tparm",
                           &fmt, &i1, &i2, &i3, &i4,
                           &i5, &i6, &i7, &i8, &i9)) {
         return NULL;