Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you cimport the libc raise function?

Tags:

cython

I could list everything I've tried, but it always ends up conflicting with the Python 'raise' keyword.

There is a strange definition in libc/signal.pxd:

int          raise_"raise" (int signum)

but I can't figure how to cimport and use it.

like image 478
Brent Baccala Avatar asked Aug 12 '26 14:08

Brent Baccala


1 Answers

The whole point of renaming the function to raise_ is to avoid the name clash with python's keyword raise.

In python call the used name should be raise_, in the C-code produced by Cython the name will be raise (but there is no longer a conflict with Python keywords).

I.e. it can be used as follow:

%%cython

from libc.signal cimport raise_
...
   raise_(1)
like image 173
ead Avatar answered Aug 14 '26 10:08

ead