python: Fix setters
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Dec 2017 19:48:49 +0000 (19:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Dec 2017 19:48:49 +0000 (19:48 +0000)
Setters however expected a tuple instead of the value directly

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/as.c
src/python/writer.c

index 3b28648..ec1573b 100644 (file)
@@ -80,11 +80,8 @@ static PyObject* AS_get_name(ASObject* self) {
        return PyUnicode_FromString(name);
 }
 
-static int AS_set_name(ASObject* self, PyObject* args) {
-       const char* name = NULL;
-
-       if (!PyArg_ParseTuple(args, "s", &name))
-               return -1;
+static int AS_set_name(ASObject* self, PyObject* value) {
+       const char* name = PyUnicode_AsUTF8(value);
 
        int r = loc_as_set_name(self->as, name);
        if (r) {
index f8a0838..6d4ea68 100644 (file)
@@ -51,11 +51,8 @@ static PyObject* Writer_get_vendor(WriterObject* self) {
        return PyUnicode_FromString(vendor);
 }
 
-static int Writer_set_vendor(WriterObject* self, PyObject* args) {
-       const char* vendor = NULL;
-
-       if (!PyArg_ParseTuple(args, "s", &vendor))
-               return -1;
+static int Writer_set_vendor(WriterObject* self, PyObject* value) {
+       const char* vendor = PyUnicode_AsUTF8(value);
 
        int r = loc_writer_set_vendor(self->writer, vendor);
        if (r) {