Skip to content

Commit 435b0f2

Browse files
committed
use C character code to simplify #5410
1 parent 8966c99 commit 435b0f2

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

PC/msvcrtmodule.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,12 @@ msvcrt_putch(PyObject *self, PyObject *args)
220220
static PyObject *
221221
msvcrt_putwch(PyObject *self, PyObject *args)
222222
{
223-
Py_UNICODE *ch;
224-
int size;
223+
int ch;
225224

226-
if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size))
225+
if (!PyArg_ParseTuple(args, "C:putwch", &ch))
227226
return NULL;
228227

229-
if (size == 0) {
230-
PyErr_SetString(PyExc_ValueError,
231-
"Expected unicode string of length 1");
232-
return NULL;
233-
}
234-
_putwch(*ch);
228+
_putwch(ch);
235229
Py_RETURN_NONE;
236230

237231
}
@@ -255,12 +249,12 @@ msvcrt_ungetch(PyObject *self, PyObject *args)
255249
static PyObject *
256250
msvcrt_ungetwch(PyObject *self, PyObject *args)
257251
{
258-
Py_UNICODE ch;
252+
int ch;
259253

260-
if (!PyArg_ParseTuple(args, "u:ungetwch", &ch))
254+
if (!PyArg_ParseTuple(args, "C:ungetwch", &ch))
261255
return NULL;
262256

263-
if (_ungetch(ch) == EOF)
257+
if (_ungetwch(ch) == WEOF)
264258
return PyErr_SetFromErrno(PyExc_IOError);
265259
Py_INCREF(Py_None);
266260
return Py_None;

0 commit comments

Comments
 (0)