swig %typemap generated list typeerror

T

txtoth

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);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top