From 8b6801a0b180ef87118e8f071eb2eeea4607baf1 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 4 Aug 2011 19:56:08 +0200 Subject: pyhbac: Do not convert int to bool --- src/python/pyhbac.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/python') diff --git a/src/python/pyhbac.c b/src/python/pyhbac.c index 230b9316..698becaa 100644 --- a/src/python/pyhbac.c +++ b/src/python/pyhbac.c @@ -709,6 +709,8 @@ HbacRule_traverse(HbacRuleObject *self, visitproc visit, void *arg) return 0; } +static int +hbac_rule_set_enabled(HbacRuleObject *self, PyObject *enabled, void *closure); static int hbac_rule_set_name(HbacRuleObject *self, PyObject *name, void *closure); @@ -718,14 +720,21 @@ HbacRule_init(HbacRuleObject *self, PyObject *args, PyObject *kwargs) const char * const kwlist[] = { "name", "enabled", NULL }; PyObject *name = NULL; PyObject *empty_tuple = NULL; + PyObject *enabled=NULL; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - sss_py_const_p(char, "O|i"), + sss_py_const_p(char, "O|O"), discard_const_p(char *, kwlist), - &name, &self->enabled)) { + &name, &enabled)) { return -1; } + if (enabled) { + if (hbac_rule_set_enabled(self, enabled, NULL) == -1) { + return -1; + } + } + if (hbac_rule_set_name(self, name, NULL) == -1) { return -1; } -- cgit