Skip to content

Commit 71d8261

Browse files
Jajcuskeszybz
authored andcommitted
Fix daemon.is_fifo and .is_mq under Python 3
The 'path' parameter was not properly converted from Unicode and the functions would always fail when a path was provided. #4
1 parent 58c65cf commit 71d8261

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

systemd/_daemon.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ static PyObject* is_fifo(PyObject *self, PyObject *args) {
142142
const char *path = NULL;
143143

144144
#if PY_MAJOR_VERSION >=3 && PY_MINOR_VERSION >= 1
145+
_cleanup_Py_DECREF_ PyObject *_path = NULL;
145146
if (!PyArg_ParseTuple(args, "i|O&:_is_fifo",
146-
&fd, Unicode_FSConverter, &path))
147+
&fd, Unicode_FSConverter, &_path))
147148
return NULL;
149+
if (_path)
150+
path = PyBytes_AsString(_path);
148151
#else
149152
if (!PyArg_ParseTuple(args, "i|z:_is_fifo", &fd, &path))
150153
return NULL;
@@ -170,9 +173,12 @@ static PyObject* is_mq(PyObject *self, PyObject *args) {
170173
const char *path = NULL;
171174

172175
#if PY_MAJOR_VERSION >=3 && PY_MINOR_VERSION >= 1
176+
_cleanup_Py_DECREF_ PyObject *_path = NULL;
173177
if (!PyArg_ParseTuple(args, "i|O&:_is_mq",
174-
&fd, Unicode_FSConverter, &path))
178+
&fd, Unicode_FSConverter, &_path))
175179
return NULL;
180+
if (_path)
181+
path = PyBytes_AsString(_path);
176182
#else
177183
if (!PyArg_ParseTuple(args, "i|z:_is_mq", &fd, &path))
178184
return NULL;

0 commit comments

Comments
 (0)