use C character code to simplify #5410

This commit is contained in:
Benjamin Peterson 2009-05-01 21:42:23 +00:00
parent 8966c99bb5
commit 435b0f2491

View File

@ -220,18 +220,12 @@ msvcrt_putch(PyObject *self, PyObject *args)
static PyObject * static PyObject *
msvcrt_putwch(PyObject *self, PyObject *args) msvcrt_putwch(PyObject *self, PyObject *args)
{ {
Py_UNICODE *ch; int ch;
int size;
if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size)) if (!PyArg_ParseTuple(args, "C:putwch", &ch))
return NULL; return NULL;
if (size == 0) { _putwch(ch);
PyErr_SetString(PyExc_ValueError,
"Expected unicode string of length 1");
return NULL;
}
_putwch(*ch);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -255,12 +249,12 @@ msvcrt_ungetch(PyObject *self, PyObject *args)
static PyObject * static PyObject *
msvcrt_ungetwch(PyObject *self, PyObject *args) msvcrt_ungetwch(PyObject *self, PyObject *args)
{ {
Py_UNICODE ch; int ch;
if (!PyArg_ParseTuple(args, "u:ungetwch", &ch)) if (!PyArg_ParseTuple(args, "C:ungetwch", &ch))
return NULL; return NULL;
if (_ungetch(ch) == EOF) if (_ungetwch(ch) == WEOF)
return PyErr_SetFromErrno(PyExc_IOError); return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;