From f893c100c0743e52b578d2108222c26321805132 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 28 May 2024 16:32:14 +1200 Subject: [PATCH] pidl:python: properly raise exception in ConvertObjectFromPythonData Without the `$self->pidl("$fail");`, the exception is not raised. We also try to improve the Python message. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 65cad3ee221..aafce9603a8 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -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);"); -- 2.47.3