pidl/Python: stop processing if fail to create a PyObject from a C type
authorStefan Metzmacher <metze@samba.org>
Tue, 9 May 2017 06:57:28 +0000 (08:57 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Feb 2019 11:48:38 +0000 (12:48 +0100)
If the conversion from a C variable into a PyObject fails
(typically is raises an Exception), we need to stop processing
and propagate the error.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Samba4/Python.pm

index efa80d7cdd1457a2e98b81907cec5a70a335347b..86e45fe1c23291ef370df51ace5fe58695a5af5d 100644 (file)
@@ -2206,6 +2206,7 @@ sub ConvertObjectToPythonLevel($$$$$$$)
                        $self->pidl("} else {");
                        $self->indent;
                        $self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
+                       $self->fail_on_null($py_var, $fail);
                        $self->deindent;
                        $self->pidl("}");
                } else {
@@ -2246,6 +2247,7 @@ sub ConvertObjectToPythonLevel($$$$$$$)
                }
                my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name, $e->{ORIGINAL});
                $self->pidl("$py_var = $conv;");
+               $self->fail_on_null($py_var, $fail);
        } elsif ($l->{TYPE} eq "SUBCONTEXT") {
                $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, $nl, $var_name, $py_var, $fail, $recurse);
        } else {