[Pyrex] char * python type with extensions

Nathaniel Haggard natester at gmail.com
Fri Jul 1 20:34:53 CEST 2005


A C function returns data in a character array.  Python wrecks this by
treating the data as a string.  To solve this I'm making an extension
type that I can treat as a python object.

cdef class const_data:
	cdef char *tc
	
	cdef void setme(self, tree_cell *t):
		self.tc = t

       def dump(self):
             ....


I was hoping it could work like this:

char * tmp
tmp = c_routine_that_returns_character_array()
a = const_data()
a.setme(tmp)
dosomething(a)

But it's trying to coerce the char * to a pyhton string instead and
that messes up the data.

Any ideas?

Nate



More information about the Pyrex mailing list