By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,944 Members | 1,819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,944 IT Pros & Developers. It's quick & easy.

swig %typemap generated list typeerror

P: n/a
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);

}

May 14 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.