Skip to content

Commit

Permalink
Fix daemon.is_fifo and .is_mq under Python 3
Browse files Browse the repository at this point in the history
The 'path' parameter was not properly converted from Unicode
and the functions would always fail when a path was provided.

#4
  • Loading branch information
Jajcus authored and keszybz committed Aug 7, 2015
1 parent 58c65cf commit 71d8261
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions systemd/_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ static PyObject* is_fifo(PyObject *self, PyObject *args) {
const char *path = NULL;

#if PY_MAJOR_VERSION >=3 && PY_MINOR_VERSION >= 1
_cleanup_Py_DECREF_ PyObject *_path = NULL;
if (!PyArg_ParseTuple(args, "i|O&:_is_fifo",
&fd, Unicode_FSConverter, &path))
&fd, Unicode_FSConverter, &_path))
return NULL;
if (_path)
path = PyBytes_AsString(_path);
#else
if (!PyArg_ParseTuple(args, "i|z:_is_fifo", &fd, &path))
return NULL;
Expand All @@ -170,9 +173,12 @@ static PyObject* is_mq(PyObject *self, PyObject *args) {
const char *path = NULL;

#if PY_MAJOR_VERSION >=3 && PY_MINOR_VERSION >= 1
_cleanup_Py_DECREF_ PyObject *_path = NULL;
if (!PyArg_ParseTuple(args, "i|O&:_is_mq",
&fd, Unicode_FSConverter, &path))
&fd, Unicode_FSConverter, &_path))
return NULL;
if (_path)
path = PyBytes_AsString(_path);
#else
if (!PyArg_ParseTuple(args, "i|z:_is_mq", &fd, &path))
return NULL;
Expand Down

0 comments on commit 71d8261

Please sign in to comment.