From 71d82616a8ae7b6d60c9d202a4c79336a7697f63 Mon Sep 17 00:00:00 2001 From: Jacek Konieczny Date: Fri, 7 Aug 2015 12:25:05 +0200 Subject: 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. https://github.com/systemd/python-systemd/pull/4 --- systemd/_daemon.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'systemd/_daemon.c') diff --git a/systemd/_daemon.c b/systemd/_daemon.c index 0b56c7e..2d552a2 100644 --- a/systemd/_daemon.c +++ b/systemd/_daemon.c @@ -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; @@ -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; -- cgit v1.2.1