systemd-python: fix initialization of _Reader objects
authorSteven Hiscocks <steven@hiscocks.me.uk>
Thu, 15 Aug 2013 16:50:32 +0000 (12:50 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Aug 2013 16:59:36 +0000 (12:59 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=995575

src/python-systemd/_reader.c

index a678f69..3b1003b 100644 (file)
@@ -64,6 +64,10 @@ static PyStructSequence_Desc Monotonic_desc = {
 };
 #endif
 
+/**
+ * Convert a Python sequence object into a strv (char**), and
+ * None into a NULL pointer.
+ */
 static int strv_converter(PyObject* obj, void *_result) {
         char ***result = _result;
         Py_ssize_t i, len;
@@ -73,6 +77,11 @@ static int strv_converter(PyObject* obj, void *_result) {
         if (!obj)
             goto cleanup;
 
+        if (obj == Py_None) {
+            *result = NULL;
+            return 1;
+        }
+
         if (!PySequence_Check(obj))
             return 0;