[systemd-commits] 3 commits - Makefile.am src/python-systemd

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Thu Aug 15 10:19:36 PDT 2013


 Makefile.am                  |    5 +++++
 src/python-systemd/_reader.c |   17 +++++++++++++++--
 src/python-systemd/login.c   |    2 +-
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit f5853dafa1b3486f3ac77fccee3cbf377baa8d95
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Aug 15 12:54:54 2013 -0400

    build-sys: add clean-python target
    
    Building for a different version of Python requires removing all
    build products for the old version. There's no nice way to do it,
    short of doing 'make clean'. The new 'clean-python' target is a
    bit hacky, but seems to work:
      ./configure PYTHON=python2 && make && make install
      make clean-python
      ./configure PYTHON=python3 --disable-gtk-doc --disable-man-pages && make && make install
    should install modules for both versions of Python.

diff --git a/Makefile.am b/Makefile.am
index 5d35993..fdfdd65 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4136,6 +4136,11 @@ CLEAN_LOCAL_HOOKS += clean-sphinx
 clean-sphinx:
 	-rm -rf docs/html/python-systemd/
 
+# Remove Python stuff, e.g. to force rebuilding for a different Python version.
+clean-python:
+	-rm -rf src/python-systemd/.libs src/python-systemd/*.l[ao]
+	-rm -f _daemon.la id128.la _journal.la login.la _reader.la
+
 # ------------------------------------------------------------------------------
 substitutions = \
        '|rootlibexecdir=$(rootlibexecdir)|' \

commit 31f49d022aee9bbb356e52e5483f182d7ffa8d2f
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Aug 15 12:51:20 2013 -0400

    systemd-python: check for oom, give nicer error messages

diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index 3b1003b..bc5db19 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -75,7 +75,7 @@ static int strv_converter(PyObject* obj, void *_result) {
         assert(result);
 
         if (!obj)
-            goto cleanup;
+            return 0;
 
         if (obj == Py_None) {
             *result = NULL;
@@ -87,6 +87,10 @@ static int strv_converter(PyObject* obj, void *_result) {
 
         len = PySequence_Length(obj);
         *result = new0(char*, len + 1);
+        if (!*result) {
+            set_error(-ENOMEM, NULL, NULL);
+            return 0;
+        }
 
         for (i = 0; i < len; i++) {
             PyObject *item;
@@ -154,7 +158,7 @@ static int Reader_init(Reader *self, PyObject *args, PyObject *keywds)
     char **files = NULL;
 
     static const char* const kwlist[] = {"flags", "path", "files", NULL};
-    if (!PyArg_ParseTupleAndKeywords(args, keywds, "|izO&", (char**) kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, keywds, "|izO&:__init__", (char**) kwlist,
                                      &flags, &path, strv_converter, &files))
         return -1;
 
diff --git a/src/python-systemd/login.c b/src/python-systemd/login.c
index 1e86193..dd2edbc 100644
--- a/src/python-systemd/login.c
+++ b/src/python-systemd/login.c
@@ -159,7 +159,7 @@ static int Monitor_init(Monitor *self, PyObject *args, PyObject *keywds)
         int r;
 
         static const char* const kwlist[] = {"category", NULL};
-        if (!PyArg_ParseTupleAndKeywords(args, keywds, "|z", (char**) kwlist,
+        if (!PyArg_ParseTupleAndKeywords(args, keywds, "|z:__init__", (char**) kwlist,
                                          &category))
                 return -1;
 

commit c2748ce28c7111037f312c5446335f5538e673e8
Author: Steven Hiscocks <steven at hiscocks.me.uk>
Date:   Thu Aug 15 12:50:32 2013 -0400

    systemd-python: fix initialization of _Reader objects
    
    https://bugzilla.redhat.com/show_bug.cgi?id=995575

diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index a678f69..3b1003b 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -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;
 



More information about the systemd-commits mailing list