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: samba-4.20.8~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37dee8f89c73dd7edfbcf68dc40c584be0d7de10;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 (cherry picked from commit 13d9231800ea969675f3207cd2c863e433104b4d) --- diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index efa5fa83e73..fb9e73c1f4b 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -990,6 +990,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) {"); @@ -998,11 +1004,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; @@ -1012,13 +1016,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}; } } }