r2805: Handle NULL pointers when converting structures to Python. All the
authorTim Potter <tpot@samba.org>
Sun, 3 Oct 2004 11:04:06 +0000 (11:04 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:36 +0000 (12:59 -0500)
test cases up till now haven't come across them yet!

source/build/pidl/swig.pm

index b3f210700175d871f19e8ed314b9a1db1eab922b..c558287945d9f4c0094daeceabb495a5f88289e9 100644 (file)
@@ -205,7 +205,10 @@ sub FieldToPython($$)
            if ($e->{ARRAY_LEN} or util::has_property($e, "size_is")) {
                $result .= ArrayToPython($e, $prefix);
            } else {
-               $result .= "\tPyDict_SetItemString(obj, \"$e->{NAME}\", $e->{TYPE}_to_python(*s->$prefix$e->{NAME}));\n";
+               $result .= "\tif (s->$prefix$e->{NAME})\n";
+               $result .= "\t\tPyDict_SetItemString(obj, \"$e->{NAME}\", $e->{TYPE}_to_python(*s->$prefix$e->{NAME}));\n";
+               $result .= "\telse\n";
+               $result .= "\t\tPyDict_SetItemString(obj, \"$e->{NAME}\", Py_None);\n";
            }
        }
     } else {