]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pidl:Python: separate logic to calculate the signature string
authorStefan Metzmacher <metze@samba.org>
Tue, 28 Jan 2025 09:27:16 +0000 (10:27 +0100)
committerJule Anger <janger@samba.org>
Mon, 3 Feb 2025 14:53:10 +0000 (14:53 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14213

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 13d9231800ea969675f3207cd2c863e433104b4d)

pidl/lib/Parse/Pidl/Samba4/Python.pm

index efa5fa83e7323139e166cf38b0db902051425c85..fb9e73c1f4b0772717a62a5ead336a7b792cb7bd 100644 (file)
@@ -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};
                        }
                }
        }