[Pyrex] Pyrex importing question.
Yann Vernier
yann at donkey.dyndns.org
Mon Nov 15 22:22:51 CET 2004
On Mon, Nov 15, 2004 at 04:11:34PM -0500, Blake Winton wrote:
> Can anyone offer me some source code to print out a stacktrace from
> C-land? I've got code in there that does it, but it tries to import the
> format_exception module, which then gives me a SystemError.
Here's a sample from a module called "Blender". Its initializer is thus
called initBlender, but the C code that links to this calls
M_Blender_Init() so that's the function I defined. You can use
PyErr_Occurred() anywhere; PyErr_Print() will print a backtrace and the
exception, then clear the error condition so the exception won't make
it further. It may not be called if there was no error.
# * since Pyrex will already have included relevant headers
# except for initBlender() which is actually from *this* module
cdef extern from *:
void PyErr_Print()
void *PyErr_Occurred()
cdef public void initBlender() # Pyrex-generated initializer
cdef public void M_Blender_Init():
initBlender()
if PyErr_Occurred():
PyErr_Print()
--
PGP fingerprint = 9242 DC15 2502 FEAB E15F 84C6 D538 EC09 5380 5746
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20041115/fd35df07/attachment.bin
More information about the Pyrex
mailing list