diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-10 16:18:49 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-10 16:18:49 (GMT) |
commit | 2f1019e7521b13fb127f53444b3ebe7116d12037 (patch) | |
tree | 9aac86f3054fb754b0e7ae54afdfcaba1c46ecb9 /PC | |
parent | 0ded5b54bb499865fb4ab8c0ac3d0977df9a334d (diff) | |
download | cpython-2f1019e7521b13fb127f53444b3ebe7116d12037.zip cpython-2f1019e7521b13fb127f53444b3ebe7116d12037.tar.gz cpython-2f1019e7521b13fb127f53444b3ebe7116d12037.tar.bz2 |
Merged revisions 59441-59449 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59442 | georg.brandl | 2007-12-09 22:15:07 +0100 (Sun, 09 Dec 2007) | 5 lines
Two fixes in DocXMLRPCServer:
* remove parameter default that didn't make sense
* properly escape values in output
Thanks to Jeff Wheeler from GHOP!
........
r59444 | georg.brandl | 2007-12-09 23:38:26 +0100 (Sun, 09 Dec 2007) | 2 lines
Add Jeff Wheeler.
........
r59445 | georg.brandl | 2007-12-09 23:39:12 +0100 (Sun, 09 Dec 2007) | 2 lines
Add DocXMLRPCServer test from GHOP task #136, written by Jeff Wheeler.
........
r59447 | christian.heimes | 2007-12-10 16:12:41 +0100 (Mon, 10 Dec 2007) | 1 line
Added wide char api variants of getch and putch to msvcrt module. The wide char methods are required to fix #1578 in py3k. I figured out that they might be useful in 2.6, too.
........
r59448 | christian.heimes | 2007-12-10 16:39:09 +0100 (Mon, 10 Dec 2007) | 1 line
Stupid save all didn't safe it all ...
........
Diffstat (limited to 'PC')
-rwxr-xr-x | PC/msvcrtmodule.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index ae6b911..a137ed0 100755 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -146,6 +146,22 @@ msvcrt_getch(PyObject *self, PyObject *args) } static PyObject * +msvcrt_getwch(PyObject *self, PyObject *args) +{ + Py_UNICODE ch; + Py_UNICODE u[1]; + + if (!PyArg_ParseTuple(args, ":getwch")) + return NULL; + + Py_BEGIN_ALLOW_THREADS + ch = _getwch(); + Py_END_ALLOW_THREADS + u[0] = ch; + return PyUnicode_FromUnicode(u, 1); +} + +static PyObject * msvcrt_getche(PyObject *self, PyObject *args) { int ch; @@ -162,6 +178,22 @@ msvcrt_getche(PyObject *self, PyObject *args) } static PyObject * +msvcrt_getwche(PyObject *self, PyObject *args) +{ + Py_UNICODE ch; + Py_UNICODE s[1]; + + if (!PyArg_ParseTuple(args, ":getwche")) + return NULL; + + Py_BEGIN_ALLOW_THREADS + ch = _getwche(); + Py_END_ALLOW_THREADS + s[0] = ch; + return PyUnicode_FromUnicode(s, 1); +} + +static PyObject * msvcrt_putch(PyObject *self, PyObject *args) { char ch; @@ -174,6 +206,26 @@ msvcrt_putch(PyObject *self, PyObject *args) return Py_None; } + +static PyObject * +msvcrt_putwch(PyObject *self, PyObject *args) +{ + Py_UNICODE *ch; + int size; + + if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size)) + return NULL; + + if (size == 0) { + PyErr_SetString(PyExc_ValueError, + "Expected unicode string of length 1"); + return NULL; + } + _putwch(*ch); + Py_RETURN_NONE; + +} + static PyObject * msvcrt_ungetch(PyObject *self, PyObject *args) { @@ -188,6 +240,19 @@ msvcrt_ungetch(PyObject *self, PyObject *args) return Py_None; } +static PyObject * +msvcrt_ungetwch(PyObject *self, PyObject *args) +{ + Py_UNICODE ch; + + if (!PyArg_ParseTuple(args, "u:ungetwch", &ch)) + return NULL; + + if (_ungetch(ch) == EOF) + return PyErr_SetFromErrno(PyExc_IOError); + Py_INCREF(Py_None); + return Py_None; +} static void insertint(PyObject *d, char *name, int value) @@ -276,6 +341,10 @@ static struct PyMethodDef msvcrt_functions[] = { {"CrtSetReportMode", msvcrt_setreportmode, METH_VARARGS}, {"set_error_mode", msvcrt_seterrormode, METH_VARARGS}, #endif + {"getwch", msvcrt_getwch, METH_VARARGS}, + {"getwche", msvcrt_getwche, METH_VARARGS}, + {"putwch", msvcrt_putwch, METH_VARARGS}, + {"ungetwch", msvcrt_ungetwch, METH_VARARGS}, {NULL, NULL} }; |