[Pyrex] Return value problems

Georg Grabler ggrabler at gmail.com
Mon May 28 19:25:19 UTC 2007


Hey lists,

I've once again a problem. Maybe minimalistic problem, but i don't seem to get 
around it.

I made a configuration object / class, which (also) wraps some c structures.

cdef extern from "list.h"
  cdef struct __list_t:
    void * data
    __list_t *prev
    __list_t *next

cdef extern from "baseh.h":
  ctypedef __list_t list_t

cdef class config:
  cdef list_t *one
  cdef list_t *two
  cdef char* xyz

This has several functions in the config.pyx as well, such as
cdef getXYZ(self)
  return self.xyz

i tried the same with def getXYZ(self)

Now well, when i now want to check actually what xyz is:

cimport config

config = config.config()
if (config.getXYZ() == NULL):
 ## more code

if (<void*>config.getXYZ() == NULL)
 ## more code

it tells me that a temporary python obeject cannot be casted:
"Cannot convert 'void (*)' to Python object"
in the 2nd case
"Casting temporary Python object to non-Python object type"

I cannot access xyz directly... well, i can, but i can't with one and two.
How to implement this? I definitely want a C type to be returned, or at least 
i want to do this comparison, since i need to check if those values are set 
before i perform any action.

Does anyone have an idea how to implement this?

Kind reagards
-- 
Yours,
Georg (STiAT)



More information about the Pyrex mailing list