swig %typemap generated list typeerror
txtoth at gmail.com
txtoth at gmail.com
Mon May 14 17:30:09 EDT 2007
I'm trying to map a security_context_t ** to a python list. After
calling the method that returns this type when I process the returned
list in a for loop I get:
TypeError: expected string or Unicode object, NoneType found
after processing the last list entry. Can anyone see what I'm doing
wrong? Do I need to do something else to the list to somehow terminate
it?
%typemap(argout) security_context_t ** {
PyObject *list_security_context = PyList_New(0); // Create the
list.
if (list_security_context) {
security_context_t **p_p_security_context_t = arg3;
while (*p_p_security_context_t) { // Move each string
into the list.
security_context_t *p_security_context_t =
*p_p_security_context_t;
if (PyList_Append(list_security_context,
PyString_FromString((char
*)*p_security_context_t)) < 0) {
fprintf(stderr, "Fail to insert item in
list.\n");
$result = -1;
break;
}
p_p_security_context_t++;
}
}
else {
fprintf(stderr, "Fail to create list.\n");
$result = -1;
}
$result = SWIG_Python_AppendOutput($result,
list_security_context);
}
More information about the Python-list
mailing list