summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-09-20 01:18:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:51 -0500
commitf41310583f2f4d77682d6d89992efd3fa69fd690 (patch)
tree9bc44e7f00676541132efe6312683be130db27ac /source4
parent6d82eaa7e9597ebaf292e21e00345be0c50287bf (diff)
downloadsamba-f41310583f2f4d77682d6d89992efd3fa69fd690.tar.gz
samba-f41310583f2f4d77682d6d89992efd3fa69fd690.tar.bz2
samba-f41310583f2f4d77682d6d89992efd3fa69fd690.zip
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)
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/swig.pm13
1 files changed, 11 insertions, 2 deletions
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";