[Pythonmac-SIG] C++ extensions, exceptions?

David Andersen dma@andrew.cmu.edu
Thu, 31 Aug 2000 10:00:41 -0400


The following very simple C++ Python extension fails on the Mac if the line
"test();" is included.  (Metrowerks C/C++ 5.3).  It appears that exception
handling is simply broken.

I can't find anything wrong with the code or the project settings.

Has anyone written an extension to Pythonmac in C++ ?

#include "python.h"

void test() {
  try {
    throw 3;
  } catch( ... ) {
  	
  }
}

extern "C"
PyObject *dmaxtnd(PyObject *self,PyObject *args)

{	int xx,yy,cc;

	if (!PyArg_ParseTuple(args,"ii",&xx,&yy))
		return(NULL);

	cc = xx+yy;
	
	test();

	return(Py_BuildValue("i",cc));

} /* dmaxtnd */


/* method table */

static PyMethodDef dmamethods[] = { {"dmaxtnd",dmaxtnd,METH_VARARGS},
									{NULL,NULL} };

extern "C"
void __declspec(dllexport) initdmaxtnd()

{
	Py_InitModule("dmaxtnd",dmamethods);
}