]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pidl:python: properly raise exception in ConvertObjectFromPythonData
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 28 May 2024 04:32:14 +0000 (16:32 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 31 May 2024 00:25:33 +0000 (00:25 +0000)
Without the `$self->pidl("$fail");`, the exception is not raised.

We also try to improve the Python message.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
pidl/lib/Parse/Pidl/Samba4/Python.pm

index 65cad3ee221ab4385f54f231ff29ca94549c7c10..aafce9603a8edb948b7eadf400f64c14ba8b8754 100644 (file)
@@ -1829,7 +1829,8 @@ sub ConvertObjectFromPythonData($$$$$$;$$)
                my $ctype_name = $self->use_type_variable($ctype);
                unless (defined ($ctype_name)) {
                        error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'");
-                       $self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " from Python\");");
+                       $self->pidl("PyErr_SetString(PyExc_TypeError, \"Cannot convert Python object to NDR $target\");");
+                       $self->pidl("$fail");
                        return;
                }
                $self->pidl("PY_CHECK_TYPE($ctype_name, $cvar, $fail);");