unable to pass void pointer to a class member

Bug #217322 reported by Johannes Wienke
2
Affects Status Importance Assigned to Milestone
Cython
Invalid
Undecided
Unassigned

Bug Description

I am unable to pass a void pointer to a class member. Im using the following code:

cpdef registerLib(self, fileName):
    # lots of code removed
    cdef void* lib = dlopen(fileName, RTLD_NOW)
    libEntry = Library()

cpdef class Library:

 cdef __name
 cdef __instances
 cdef __instCount
 cdef void* handle

 def __init__(self):
  self.__instances = []
  self.__instCount = 0

This code reports th error:

Error converting Pyrex file to C:
------------------------------------------------------------
...
  libEntry = Library()
  libEntry.handle = lib
                      ^
------------------------------------------------------------

/home/languitar/BA-workspace/shIP/csrc/cloader.pyx:48:23: Cannot convert 'void *' to Python object

The same thing happens if I try to use a setter function and any other combination of cdef, cpdef and so on I tried.

Revision history for this message
robertwb (robertwb) wrote :

You must declare libEntry to be of type Library, i.e.

cdef Library libEntry = Library

Changed in cython:
status: New → Invalid
Revision history for this message
Johannes Wienke (languitar) wrote :

Thanks for the hint, but that results in this error:

  cpdef Library libEntry = Library()
               ^
------------------------------------------------------------

/home/languitar/BA-workspace/shIP/csrc/cloader.pyx:47:16: Syntax error in C variable declaration

Revision history for this message
Johannes Wienke (languitar) wrote :

Oh, I meant cdef, not cpdef, error is the same.

Revision history for this message
robertwb (robertwb) wrote : Re: [Bug 217322] Re: unable to pass void pointer to a class member

On Apr 14, 2008, at 9:38 AM, Johannes Wienke wrote:
> Oh, I meant cdef, not cpdef, error is the same.

This is probably because you define this function before you define
the cdef class Library.

- Robert

Revision history for this message
Johannes Wienke (languitar) wrote :

Thanks! Things you don't normally think of, when you're used to programming in Java. ;)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.