title: Cython: Cannot convert Python object to struct
body: <p>Warning: I am pretty newbie with Cython. :D
  I have the following pieces of code:</p>
  
  <p>my_structs.h:</p>
  
  <pre><code>typedef struct Dataset{
      int lines;
      char **tid;
  }Dataset;
  </code></pre>
  
  <p>myiolib.pyx:</p>
  
  <pre><code>from libc.stdlib cimport malloc
  from libc.string cimport strcpy
  from cpython.string cimport PyString_AsString
  
  cdef extern from "my_structs.h":
      cdef struct Dataset:
          int lines
          char **tid
  
  
  cdef Dataset readDataset(TID_name):
      cdef:
          int i, line_count=0
          Dataset instance
  
      with open(TID_name, 'rU') as file_iter:
          for line in file_iter:
              line_count=line_count+1
  
      instance.tid = &lt;char **&gt;malloc(line_count * sizeof(char *))
  
      i = 0
      with open(TID_name, 'rU') as file_iter:
          for line in file_iter:
              instance.tid[i] = &lt;char *&gt;malloc((len(line)+1) * sizeof(char ))
              strcpy(instance.tid[i], PyString_AsString(line.strip()))
              i += 1
  
      instance.lines = line_count
      return instance
  </code></pre>
  
  <p>mytest.pyx:</p>
  
  <pre><code>import myiolib
  
  cdef extern from "my_structs.h":
      cdef struct Dataset:
          int lines
          char **tid
  
  
  def test():
      cdef Dataset D
      D = myiolib.readDataset("test.dat")
  
      # Do something...
      # Free memory (?!)
  </code></pre>
  
  <p>test.py:</p>
  
  <pre><code>import mytest
  
  mytest.test()
  </code></pre>
  
  <p>When I type: cython -a mytest.pyx it says: "Cannot convert Python object to 'Dataset' ", 
  pointing at D = myiolib.readDataset("test.dat").
  Why? I don't understand... What am I doing wrong?</p>