From: Stefan Metzmacher Date: Tue, 28 Jan 2025 09:27:16 +0000 (+0100) Subject: pidl:Python: separate logic to calculate the signature string X-Git-Tag: tdb-1.4.13~71 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=13d9231800ea969675f3207cd2c863e433104b4d;p=thirdparty%2Fsamba.git pidl:Python: separate logic to calculate the signature string BUG: https://bugzilla.samba.org/show_bug.cgi?id=14213 Signed-off-by: Stefan Metzmacher Reviewed-by: Douglas Bagnall --- diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 253bac1e9bd..e5d9ee05bd9 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -1040,6 +1040,12 @@ sub PythonFunctionUnpackOut($$$) $self->pidl("PyObject *result = NULL;"); $self->pidl(""); + if ($result_size > 1) { + $signature .= "("; + } elsif ($result_size == 0) { + $signature .= "None"; + } + if ($result_size > 1) { $self->pidl("result = PyTuple_New($result_size);"); $self->pidl("if (result == NULL) {"); @@ -1048,11 +1054,9 @@ sub PythonFunctionUnpackOut($$$) $self->deindent; $self->pidl("}"); $self->pidl(""); - $signature .= "("; } elsif ($result_size == 0) { $self->pidl("result = Py_None;"); $self->pidl("Py_INCREF(result);"); - $signature .= "None"; } my $i = 0; @@ -1062,13 +1066,17 @@ sub PythonFunctionUnpackOut($$$) my $py_name = "py_$e->{NAME}"; if (grep(/out/,@{$e->{DIRECTION}})) { $self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name, "return NULL;"); + if ($result_size > 1) { + $signature .= "$e->{NAME}, "; + } else { + $signature .= $e->{NAME}; + } + if ($result_size > 1) { $self->pidl("PyTuple_SetItem(result, $i, $py_name);"); $i++; - $signature .= "$e->{NAME}, "; } else { $self->pidl("result = $py_name;"); - $signature .= $e->{NAME}; } } }