$res .= "\tstruct $fn->{NAME} *s;\n\n";
$res .= "\tif (!PyDict_Check(obj)) {\n";
- $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for %s\", name);\n";
+ $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n";
$res .= "\t\treturn NULL;\n";
$res .= "\t}\n\n";
$res .= "%typemap(in) struct $fn->{NAME} * {\n";
$res .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(int) $fn->{NAME}\");\n\n";
- $res .= "\t\$1 = $fn->{NAME}_ptr_from_python(mem_ctx, \$input, \"<function params>\");\n";
+ $res .= "\t\$1 = $fn->{NAME}_ptr_from_python(mem_ctx, \$input, \"<function params>\");\n\n";
+
+ $res .= "\tif (PyErr_Occurred())\n";
+ $res .= "\t\t\treturn NULL;\n\n";
+
$res .= "}\n\n";
# Output typemap
$res .= "\tPyObject *dict;\n";
$res .= "\n";
- $res .= "\tif (PyErr_Occurred())\n";
- $res .= "\t\t\treturn NULL;\n\n";
-
$res .= "\tif (status != 0) {\n";
$res .= "\t\tset_ntstatus_exception(status);\n";
$res .= "\t\treturn NULL;\n";
$res .= "{\n";
$res .= "\tstruct $s->{NAME} *s;\n\n";
+ $res .= "\tif (obj == NULL) {\n";
+ $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n";
+ $res .= "\t\treturn NULL;\n";
+ $res .= "\t}\n\n";
+
$res .= "\tif (obj == Py_None) {\n";
$res .= "\t\treturn NULL;\n";
$res .= "\t}\n\n";
$res .= "\tif (!PyDict_Check(obj)) {\n";
- $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for %s\", name);\n";
+ $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n";
$res .= "\t\treturn NULL;\n";
$res .= "\t}\n\n";
$res .= "void $s->{NAME}_from_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s, PyObject *obj, char *name)\n";
$res .= "{\n";
+ $res .= "\tif (obj == NULL) {\n";
+ $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n";
+ $res .= "\t\treturn;\n";
+ $res .= "\t}\n\n";
+
$res .= "\tif (!PyDict_Check(obj)) {\n";
- $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for %s\", name);\n";
+ $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n";
$res .= "\t\treturn;\n";
$res .= "\t}\n\n";
$res .= "\tunion $u->{NAME} *u;\n";
$res .= "\tPyObject *dict;\n\n";
+ $res .= "\tif (obj == NULL) {\n";
+ $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n";
+ $res .= "\t\treturn NULL;\n";
+ $res .= "\t}\n\n";
+
$res .= "\tif (!PyDict_Check(obj)) {\n";
- $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for %s\", name);\n";
+ $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n";
$res .= "\t\treturn NULL;\n";
$res .= "\t}\n\n";
$res .= "{\n";
$res .= "\tPyObject *dict;\n\n";
+ $res .= "\tif (obj == NULL) {\n";
+ $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n";
+ $res .= "\t\treturn;\n";
+ $res .= "\t}\n\n";
+
$res .= "\tif (!PyDict_Check(obj)) {\n";
- $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for %s\", name);\n";
+ $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n";
$res .= "\t\treturn;\n";
$res .= "\t}\n\n";
uint8 uint8_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name);
return 0;
uint16 uint16_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name);
return 0;
uint32 uint32_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name);
return 0;
int64 int64_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name);
return 0;
uint64 uint64_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting int value for %s", name);
return 0;
NTTIME NTTIME_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name);
return 0;
HYPER_T HYPER_T_from_python(PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return 0;
+ }
+
if (!PyInt_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting integer value for %s", name);
return 0;
char *string_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)
{
+ if (obj == NULL) {
+ PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
+ return NULL;
+ }
+
if (obj == Py_None)
return NULL;
if (!PyString_Check(obj)) {
PyErr_Format(PyExc_TypeError, "Expecting string value for %s", name);
- return 0;
+ return NULL;
}
return PyString_AsString(obj);