[Pyrex] cdef object in cdef class: Segmentation fault

Paul Prescod paul at prescod.net
Wed Jan 14 01:13:20 CET 2004


Simon Burton wrote:

> So far I have had no luck wrapping structs with c extension classes :(
> 
> I have reduced it to the following code:
> 
> #BEGIN
> 
> cdef class Bomber:
>   cdef object handle
>   def __init__(self,name):
>     self.handle = name
> 
> b = Bomber("some")

Maybe I misunderstand your question.I don't see any use of "structs" in 
this code. What do you mean by struct?

Where is the definition of the C struct type?

Here's some code I've used to deal with structs.

http://www.prescod.net/python/pyrexopt/pyxpat/pyxpat.pyx

cdef extern from "expat/expat.h":
	cdef struct XML_ParserStruct
	cdef XML_Parser XML_ParserCreate(XML_Char *encodingName)


cdef class ExpatParser:
	cdef XML_Parser _parser

	def __init__(self, char *encoding):
		self._parser = XML_ParserCreate(encoding)

Does that help?


  Paul Prescod






More information about the Pyrex mailing list