chiark / gitweb /
systemd-python: add Journal method to add MESSAGE_ID match
[elogind.git] / src / python-systemd / _reader.c
index 95e60941622356ac2d5f3a35cd04e19b46550070..b754014e9bc50d8a27bceac0ecdf5a3ba03a4182 100644 (file)
@@ -57,7 +57,7 @@ Journal_init(Journal *self, PyObject *args, PyObject *keywds)
     char *path=NULL;
 
     static char *kwlist[] = {"flags", "path", NULL};
-    if (! PyArg_ParseTupleAndKeywords(args, keywds, "|is", kwlist,
+    if (! PyArg_ParseTupleAndKeywords(args, keywds, "|iz", kwlist,
                                       &flags, &path))
         return 1;
 
@@ -326,8 +326,7 @@ Journal_seek(Journal *self, PyObject *args, PyObject *keywds)
         PyErr_SetString(PyExc_ValueError, "Invalid value for whence");
     }
 
-    if (result)
-        Py_DECREF(result);
+    Py_XDECREF(result);
     if (PyErr_Occurred())
         return NULL;
     Py_RETURN_NONE;
@@ -498,6 +497,8 @@ Journal_iternext(PyObject *self)
     Py_ssize_t dict_size;
 
     dict = PyObject_CallMethod(self, "get_next", "");
+    if (PyErr_Occurred())
+        return NULL;
     dict_size = PyDict_Size(dict);
     if ((int64_t) dict_size > 0LL) {
         return dict;
@@ -508,7 +509,6 @@ Journal_iternext(PyObject *self)
     }
 }
 
-#ifdef SD_JOURNAL_FOREACH_UNIQUE
 PyDoc_STRVAR(Journal_query_unique__doc__,
 "query_unique(field) -> a set of values\n\n"
 "Returns a set of unique values in journal for given `field`.\n"
@@ -554,7 +554,6 @@ Journal_query_unique(Journal *self, PyObject *args)
     Py_DECREF(key);
     return value_set;
 }
-#endif //def SD_JOURNAL_FOREACH_UNIQUE
 
 static PyObject *
 Journal_get_data_threshold(Journal *self, void *closure)
@@ -637,16 +636,14 @@ static PyMethodDef Journal_methods[] = {
     Journal_wait__doc__},
     {"seek_cursor", (PyCFunction)Journal_seek_cursor, METH_VARARGS,
     Journal_seek_cursor__doc__},
-#ifdef SD_JOURNAL_FOREACH_UNIQUE
     {"query_unique", (PyCFunction)Journal_query_unique, METH_VARARGS,
     Journal_query_unique__doc__},
-#endif
     {NULL}  /* Sentinel */
 };
 
 static PyTypeObject JournalType = {
     PyVarObject_HEAD_INIT(NULL, 0)
-    "_reader.Journal",           /*tp_name*/
+    "_reader._Journal",               /*tp_name*/
     sizeof(Journal),                  /*tp_basicsize*/
     0,                                /*tp_itemsize*/
     (destructor)Journal_dealloc,      /*tp_dealloc*/