The function is a cdef extension type's method. Here the part of the
implementation which raises the exceptions:

  cdef void *getItem( self, int i ) except NULL:
    cdef void* tmpPtr

    # Check NULL pointer
    if self.rawPtr == NULL:
      raise ValueError( "Null pointer" )
    # Check specified index
    if i < 0:
      raise IndexError( "Unvalid index" )
    # Bound checking
    if self._layout[0] > 0 and i >= self._layout[0]:
      raise IndexError( "Index out of bounds" )

    # Code used for get the i-th value
    .......

self.rawPtr is the void pointer stored by the extension type.
self._layout is a simple tuple which defines the "shape" of
self.rawPtr, used for bounds checking. The function is called by other
extension types which extend the extension type which defines the
getItem method. What do you main with "The "except NULL" is for
propagating within-Cython exceptions"? Do I need to put the getItem
call in a try-except block in the cython caller?

Daniele

2009/2/3 Dag Sverre Seljebotn <[email protected]>:
> Daniele Pianu wrote:
>> Probably I've not completely understood the C-function
>> exception-propagating mechanism. I've a function with a prototype like
>> this
>>
>> void* getItem( void* self, int i )
>>
> Where is this function declared? What kind of exception is raised? C has
> no exceptions, and C++ exception needs a different form of declaration:
> *http://docs.cython.org/docs/pyrex_differences.html#c-exception-handling*
>
> The "except NULL" is for propagating within-Cython exceptions, see
> http://docs.cython.org/docs/language_basics.html#error-return-values
>
> Is this the reason for your problem? I might be missing the mark here.
>
> Dag Sverre
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to