From 23abef53590bf3dd6f88ff4dbe81e306abfa4386 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 30 Nov 2017 20:50:25 +0100 Subject: Marked some arguments as optional for loading formats with Python. --- ChangeLog | 6 ++++++ plugins/dex/python/format.c | 5 ++++- plugins/elf/python/format.c | 12 +++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30c1bcd..07fc007 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +17-11-30 Cyrille Bagard + + * plugins/dex/python/format.c: + * plugins/elf/python/format.c: + Mark some arguments as optional for loading formats with Python. + 17-11-29 Cyrille Bagard * plugins/elf/dynamic.c: diff --git a/plugins/dex/python/format.c b/plugins/dex/python/format.c index 74f6eae..906b09a 100644 --- a/plugins/dex/python/format.c +++ b/plugins/dex/python/format.c @@ -77,7 +77,10 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject GtkStatusStack *status; /* Instance GTK de suivi */ GBinFormat *format; /* Création GLib à transmettre */ - ret = PyArg_ParseTuple(args, "OOO", &content_obj, &parent_obj, &status_obj); + parent_obj = Py_None; + status_obj = Py_None; + + ret = PyArg_ParseTuple(args, "O|OO", &content_obj, &parent_obj, &status_obj); if (!ret) return NULL; ret = PyObject_IsInstance(content_obj, (PyObject *)get_python_binary_content_type()); diff --git a/plugins/elf/python/format.c b/plugins/elf/python/format.c index eb1bedb..a5e93d7 100644 --- a/plugins/elf/python/format.c +++ b/plugins/elf/python/format.c @@ -73,9 +73,19 @@ static PyObject *py_elf_format_new(PyTypeObject *type, PyObject *args, PyObject GtkStatusStack *status; /* Instance GTK de suivi */ GBinFormat *format; /* Création GLib à transmettre */ - ret = PyArg_ParseTuple(args, "O!OO", get_python_binary_content_type(), &content_obj, &parent_obj, &status_obj); + parent_obj = Py_None; + status_obj = Py_None; + + ret = PyArg_ParseTuple(args, "O|OO", &content_obj, &parent_obj, &status_obj); if (!ret) return NULL; + ret = PyObject_IsInstance(content_obj, (PyObject *)get_python_binary_content_type()); + if (!ret) + { + PyErr_SetString(PyExc_TypeError, _("The first argument must be an instance of BinContent.")); + return NULL; + } + content = G_BIN_CONTENT(pygobject_get(content_obj)); if (parent_obj == Py_None) -- cgit v0.11.2-87-g4458