From f41310583f2f4d77682d6d89992efd3fa69fd690 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 20 Sep 2004 01:18:10 +0000 Subject: r2425: Found another place for a type check. When convert a dictionary value to an array, check that the value exists and it is of list type. Fix a typo. (This used to be commit bcee3860554260bca2bbb6fd73d8770a4997c041) --- source4/build/pidl/swig.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/build') diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index 9736c56eb1..042587a538 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -67,6 +67,16 @@ sub ArrayFromPython($$) $result .= "\ts->$prefix$e->{NAME} = talloc(mem_ctx, $array_len * sizeof($type));\n"; } + $result .= "\tif (!PyDict_GetItemString(obj, \"$e->{NAME}\")) {\n"; + $result .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", \"$e->{NAME}\");\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; + + $result .= "\tif (!PyList_Check(PyDict_GetItemString(obj, \"$e->{NAME}\"))) {\n"; + $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting list value for key '%s'\", \"$e->{NAME}\");\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; + $result .= "\t{\n"; $result .= "\t\tint i;\n\n"; @@ -326,8 +336,7 @@ sub ParseStruct($) $result .= "\t\treturn NULL;\n"; $result .= "\t}\n\n"; - $result .= "\tif (obj == Py_None) return NULL;\n"; - $result .= "\t}\n\n"; + $result .= "\tif (obj == Py_None) return NULL;\n\n"; $result .= "\tif (!PyDict_Check(obj)) {\n"; $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; -- cgit