diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-25 00:21:36 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-25 00:21:36 (GMT) |
commit | 8d3654db2228b11b7fbfac49ebffbe85a69e9a52 (patch) | |
tree | e9784866621eadc8f7543171cf69918647605d59 /Modules/syslogmodule.c | |
parent | a401bbe5f0cadc7b0e26570b96c175cce583661c (diff) | |
download | cpython-8d3654db2228b11b7fbfac49ebffbe85a69e9a52.zip cpython-8d3654db2228b11b7fbfac49ebffbe85a69e9a52.tar.gz cpython-8d3654db2228b11b7fbfac49ebffbe85a69e9a52.tar.bz2 |
Use unicode and add a "test" for syslog
Diffstat (limited to 'Modules/syslogmodule.c')
-rw-r--r-- | Modules/syslogmodule.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 4a77916..08e4a36 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -58,9 +58,10 @@ syslog_openlog(PyObject * self, PyObject * args) long logopt = 0; long facility = LOG_USER; PyObject *new_S_ident_o; + const char *ident; if (!PyArg_ParseTuple(args, - "S|ll;ident string [, logoption [, facility]]", + "U|ll;ident string [, logoption [, facility]]", &new_S_ident_o, &logopt, &facility)) return NULL; @@ -71,7 +72,10 @@ syslog_openlog(PyObject * self, PyObject * args) S_ident_o = new_S_ident_o; Py_INCREF(S_ident_o); - openlog(PyString_AsString(S_ident_o), logopt, facility); + ident = PyUnicode_AsString(S_ident_o); + if (ident == NULL) + return NULL; + openlog(ident, logopt, facility); Py_INCREF(Py_None); return Py_None; @@ -81,17 +85,21 @@ syslog_openlog(PyObject * self, PyObject * args) static PyObject * syslog_syslog(PyObject * self, PyObject * args) { - char *message; + PyObject *message_object; + const char *message; int priority = LOG_INFO; - if (!PyArg_ParseTuple(args, "is;[priority,] message string", - &priority, &message)) { + if (!PyArg_ParseTuple(args, "iU;[priority,] message string", + &priority, &message_objecct)) { PyErr_Clear(); - if (!PyArg_ParseTuple(args, "s;[priority,] message string", - &message)) + if (!PyArg_ParseTuple(args, "U;[priority,] message string", + &message_objecct)) return NULL; } + message = PyUnicode_AsString(message_object); + if (message == NULL) + return NULL; syslog(priority, "%s", message); Py_INCREF(Py_None); return Py_None; |