]> 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)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 29 Jan 2025 01:14:40 +0000 (01:14 +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>
pidl/lib/Parse/Pidl/Samba4/Python.pm

index 253bac1e9bdf1223048502efe614ffc4ccabbf87..e5d9ee05bd9c2d840d62f2ccfe967720dc64d114 100644 (file)
@@ -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};
                        }
                }
        }