@@ -58,9 +58,10 @@ syslog_openlog(PyObject * self, PyObject * args)
5858 long logopt = 0 ;
5959 long facility = LOG_USER ;
6060 PyObject * new_S_ident_o ;
61+ const char * ident ;
6162
6263 if (!PyArg_ParseTuple (args ,
63- "S |ll;ident string [, logoption [, facility]]" ,
64+ "U |ll;ident string [, logoption [, facility]]" ,
6465 & new_S_ident_o , & logopt , & facility ))
6566 return NULL ;
6667
@@ -71,7 +72,10 @@ syslog_openlog(PyObject * self, PyObject * args)
7172 S_ident_o = new_S_ident_o ;
7273 Py_INCREF (S_ident_o );
7374
74- openlog (PyString_AsString (S_ident_o ), logopt , facility );
75+ ident = PyUnicode_AsString (S_ident_o );
76+ if (ident == NULL )
77+ return NULL ;
78+ openlog (ident , logopt , facility );
7579
7680 Py_INCREF (Py_None );
7781 return Py_None ;
@@ -81,17 +85,21 @@ syslog_openlog(PyObject * self, PyObject * args)
8185static PyObject *
8286syslog_syslog (PyObject * self , PyObject * args )
8387{
84- char * message ;
88+ PyObject * message_object ;
89+ const char * message ;
8590 int priority = LOG_INFO ;
8691
87- if (!PyArg_ParseTuple (args , "is ;[priority,] message string" ,
88- & priority , & message )) {
92+ if (!PyArg_ParseTuple (args , "iU ;[priority,] message string" ,
93+ & priority , & message_objecct )) {
8994 PyErr_Clear ();
90- if (!PyArg_ParseTuple (args , "s ;[priority,] message string" ,
91- & message ))
95+ if (!PyArg_ParseTuple (args , "U ;[priority,] message string" ,
96+ & message_objecct ))
9297 return NULL ;
9398 }
9499
100+ message = PyUnicode_AsString (message_object );
101+ if (message == NULL )
102+ return NULL ;
95103 syslog (priority , "%s" , message );
96104 Py_INCREF (Py_None );
97105 return Py_None ;
0 commit comments