net: Allow Python commands to return None instead of 0.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 30 Dec 2009 17:01:24 +0000 (18:01 +0100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 31 Dec 2009 06:33:21 +0000 (17:33 +1100)
Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/utils/net/net.c

index ee5cdf8e1c477049be708e87abdb097d0403cb61..ba935b998667b3c82aff1dc4d2d512b1098eb1e2 100644 (file)
@@ -94,7 +94,14 @@ static int py_call_with_string_args(PyObject *self, const char *method, int argc
                return 1;
        }
 
-       return PyInt_AsLong(ret);
+       if (ret == Py_None) {
+               return 0;
+       } else if (PyInt_Check(ret)) {
+               return PyInt_AsLong(ret);
+       } else {
+               fprintf(stderr, "Function return value type unexpected.\n");
+               return -1;
+       }
 }
 
 static PyObject *py_commands(void)