components/python/python27/patches/15-get_wch.patch
author John Beck <John.Beck@Oracle.COM>
Sat, 04 Oct 2014 14:50:43 -0700
branchs11-update
changeset 3367 ed5024e47b53
parent 2386 4b1a9590af26
permissions -rw-r--r--
PSARC 2014/183 Python 2.7.6 18251953 update Python 2.7 line to version 2.7.6 19004605 update Python 2.7 line to version 2.7.7 19308541 update Python 2.7 line to version 2.7.8 19284990 python 2.7.7 segfaults while under memory stress 17431625 64-bit python should use long rather than int for os.sysconf() return value 19164544 Python 2.7 test_tcl fails 19030238 Python 2.7 test_sysconfig fails - no module named _osx_support 19030198 Python 2.7 tests fail - import name error 19032456 more Python 2.7 tests failing with import errors 19022543 Python 2.7 test_lib2to3 fails
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3367
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
     1
This patch adds wget_wch support to the curses module.  It may be contributed
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
     2
upstream at some point, but the suitability (or lack thereof) has not yet
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
     3
been determined.
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
     4
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
     5
--- Python-2.7.6/Modules/_cursesmodule.c.~1~	2013-11-09 23:36:41.000000000 -0800
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
     6
+++ Python-2.7.6/Modules/_cursesmodule.c	2014-05-14 13:36:59.388642793 -0700
2386
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
@@ -861,6 +861,37 @@
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
 }
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
 
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
 static PyObject *
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
+PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
+{
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
+    int x, y;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
+    int ct;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
+    wint_t rtn;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
+
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
+    switch (PyTuple_Size(args)) {
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
+    case 0:
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
+        Py_BEGIN_ALLOW_THREADS
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+        ct = wget_wch(self->win,&rtn);
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
+        Py_END_ALLOW_THREADS
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
+        break;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
+    case 2:
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
+            return NULL;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
+        Py_BEGIN_ALLOW_THREADS
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
+        ct = mvwget_wch(self->win,y,x,&rtn);
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
+        Py_END_ALLOW_THREADS
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
+        break;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
+    default:
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
+        PyErr_SetString(PyExc_TypeError, "get_wch requires 0 or 2 arguments");
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
+        return NULL;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
+    }
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
+    if (ct == ERR) {
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
+        PyErr_SetString(PyCursesError, "get_wch failed");
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
+        return NULL;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
+    }
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
+    return PyInt_FromLong((long)rtn);
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
+}
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
+
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
+static PyObject *
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
 PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
 {
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
     int x, y;
3367
ed5024e47b53 PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 2386
diff changeset
    45
@@ -1572,6 +1603,7 @@
2386
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
     {"getbegyx",        (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
     {"getbkgd",         (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
     {"getch",           (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
+    {"get_wch",         (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
     {"getkey",          (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    51
     {"getmaxyx",        (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    52
     {"getparyx",        (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},