From 88044453fc72a2c629a4eb36956bbefb5d066356 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 4 Mar 2012 17:23:46 +0100 Subject: [PATCH] python: fix return value of emptiness_check_instantiator * wrap/python/spot.i: Fix typemap for emptiness_check_instantiator::construct. The previous code used to turn (None, "error") into simply ("error"). * wrap/python/ajax/spot.in: Fix handling or errors when instantiating emptiness checks. --- ChangeLog | 10 ++++++++++ wrap/python/ajax/spot.in | 1 + wrap/python/spot.i | 22 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c37e3c6be..90292f788 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-03-04 Alexandre Duret-Lutz + + python: fix return value of emptiness_check_instantiator + + * wrap/python/spot.i: Fix typemap for + emptiness_check_instantiator::construct. The previous code used + to turn (None, "error") into simply ("error"). + * wrap/python/ajax/spot.in: Fix handling or errors when + instantiating emptiness checks. + 2012-02-25 Alexandre Duret-Lutz * NEWS: Summarize recent changes. diff --git a/wrap/python/ajax/spot.in b/wrap/python/ajax/spot.in index 18425b35e..3347b3a58 100755 --- a/wrap/python/ajax/spot.in +++ b/wrap/python/ajax/spot.in @@ -489,6 +489,7 @@ if output_type == 'r': if not eci: unbufprint('
Cannot parse "' + opt + '" near "' + err + '".
') + ec = 0 else: ec_a = 0 n_acc = degen.number_of_acceptance_conditions() diff --git a/wrap/python/spot.i b/wrap/python/spot.i index 271e8f572..fa8ad89cf 100644 --- a/wrap/python/spot.i +++ b/wrap/python/spot.i @@ -110,8 +110,26 @@ using namespace spot; // function that return errors via a "char **err" argument. %typemap(in, numinputs=0) char** OUTPUT (char* temp) "$1 = &temp;"; -%typemap(argout, fragment="t_output_helper") char** OUTPUT - "$result = t_output_helper($result, SWIG_FromCharPtr(*$1));"; +%typemap(argout) char** OUTPUT { + PyObject *obj = SWIG_FromCharPtr(*$1); + if (!$result) { + $result = obj; + //# If the function returns null_ptr (i.e. Py_None), we + //# don't want to override it with OUTPUT as in the + //# default implementation of t_output_helper. + // } else if ($result == Py_None) { + // Py_DECREF($result); + // $result = obj; + } else { + if (!PyList_Check($result)) { + PyObject *o2 = $result; + $result = PyList_New(1); + PyList_SetItem($result, 0, o2); + } + PyList_Append($result,obj); + Py_DECREF(obj); + } + }; %apply char** OUTPUT { char** err }; // False and True cannot be redefined in Python3, even in a class. -- GitLab