swig %typemap generated list typeerror

Discussion in 'Python' started by txtoth@gmail.com, May 14, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Istvan Albert

    SWIG typemap leading to a memory leak

    Istvan Albert, Aug 18, 2003, in forum: Python
    Replies:
    2
    Views:
    333
    Istvan Albert
    Aug 19, 2003
  2. Replies:
    0
    Views:
    345
  3. SWIG typemap problem

    , Apr 4, 2006, in forum: Ruby
    Replies:
    0
    Views:
    130
  4. SWIG typemap problem

    , Apr 4, 2006, in forum: Ruby
    Replies:
    0
    Views:
    98
  5. BENI

    SWIG typemap for ta-lib

    BENI, Mar 13, 2007, in forum: Ruby
    Replies:
    7
    Views:
    188
    barabba
    Mar 21, 2007
Loading...

Share This Page