summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Konieczny <j.konieczny@eggsoft.pl>2015-08-07 12:25:05 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-08-07 11:49:42 -0400
commit71d82616a8ae7b6d60c9d202a4c79336a7697f63 (patch)
tree069ddf0f89410206610351fb122a7c0ff3acc1c4
parent58c65cf10a7640669ef84f9119c7841112eea025 (diff)
downloadpython-systemd-71d82616a8ae7b6d60c9d202a4c79336a7697f63.tar.gz
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
-rw-r--r--systemd/_daemon.c10
1 files changed, 8 insertions, 2 deletions
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;