[Pyrex] ability to return NULL from a def function
sjmachin at lexicon.net
sjmachin at lexicon.net
Sun Jan 30 01:55:20 CET 2005
Consider this:
cdef extern from "python.h":
int Py_XXX(int arg1) except -1
def myfunc():
# acquire bags of resources, create reference cycles, call malloc(), whatever
answer = PyXXX(something)
# failure means no chance to clean up
SO ...
still have to carry on like a hand-coded C function:
cdef extern from "python.h":
int Py_XXX(int arg1) # NO except
cdef int bogoff() except --2
return -2
# I'm the Kludge King, aren't I!?
def myfunc():
# acquire bags of resources, create reference cycles, call malloc(), whatever
answer = PyXXX(something)
if answer == -1:
cleanup()
bogoff()
So, any possibility of syntactical sugar to replace bogoff() ?
Cheers,
John
More information about the Pyrex
mailing list