Casting the exception return code raises compile error

14 views
Skip to first unread message

Venkat Raghav Rajagopalan (Raghav RV)

unread,
Dec 29, 2016, 1:35:30 AM12/29/16
to cython-users
Hi,

I am trying to allow NULL as an except error code (return value is a better term for this?) for a function whose return type is pointer to one of the fused types (decided based on the input). I'm unable to find a nice solution "other than except *" whose overhead is pretty significant especially when the function is being called multiple times...

A fully contained sample cython snippet would be -


%%cython

ctypedef fused realloc_ptr
:
   
(unsigned char*)
   
(size_t*)
   
cdef realloc_ptr safe_realloc
(realloc_ptr* p) nogil except (<realloc_ptr> NULL):
   
with gil:
       
raise MemoryError("I ain't gonna work...")
   
return NULL


cpdef fn
():
    cdef size_t
* a
    safe_realloc
(&a)
   
fn
()


Thanks!
Reply all
Reply to author
Forward
0 new messages