diff options
| author | ghost <andreas.monzner@multimedia-labs.de> | 2010-07-05 16:59:47 +0200 |
|---|---|---|
| committer | ghost <andreas.monzner@multimedia-labs.de> | 2010-07-05 17:00:10 +0200 |
| commit | 8800ca10e88061b317c256f3fa90ecf486551648 (patch) | |
| tree | c6cbe07c1d2f44ac49f67d1638c1ef6afa6aea38 /lib/base/console.cpp | |
| parent | 3091a2b24f33463ca209efacd5fcca5f349e4ef5 (diff) | |
| download | enigma2-8800ca10e88061b317c256f3fa90ecf486551648.tar.gz enigma2-8800ca10e88061b317c256f3fa90ecf486551648.zip | |
lib/base/console.cpp: fix eConsoleAppContainer write (when called with one string only)
Diffstat (limited to 'lib/base/console.cpp')
| -rw-r--r-- | lib/base/console.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/base/console.cpp b/lib/base/console.cpp index add87066..43f9f61e 100644 --- a/lib/base/console.cpp +++ b/lib/base/console.cpp @@ -516,18 +516,15 @@ eConsolePy_write(eConsolePy* self, PyObject *args) { int len; char *data; - if (PyArg_ParseTuple(args, "si", &data, &len)) - ; - else + int ret = -1; + Py_ssize_t argc = PyTuple_Size(args); + if (argc > 1) + ret = PyArg_ParseTuple(args, "si", &data, &len); + else if (argc == 1) { PyObject *ob; - if (!PyArg_ParseTuple(args, "O", &ob) || !PyString_Check(ob)) - { - PyErr_SetString(PyExc_TypeError, - "1st arg must be a string, optionaly 2nd arg can be the string length"); - return NULL; - } - else + ret = !PyArg_ParseTuple(args, "O", &ob) || !PyString_Check(ob); + if (!ret) { Py_ssize_t length; if (!PyString_AsStringAndSize(ob, &data, &length)) @@ -536,6 +533,12 @@ eConsolePy_write(eConsolePy* self, PyObject *args) len = 0; } } + if (ret) + { + PyErr_SetString(PyExc_TypeError, + "1st arg must be a string, optionaly 2nd arg can be the string length"); + return NULL; + } self->cont->write(data, len); Py_RETURN_NONE; } |
