SWIG extension crashes

Andrew Gregory andrew.gregory at npl.co.uk
Thu Mar 6 13:09:34 EST 2003


Using this minimal extension,

class MyClass
{ 

public:
  MyClass() { };  // Constructor
  ~MyClass() { }; // destructor               
  PyObject* Mysend();

};

PyObject* MyClass::Mysend()
 {
    return Py_None;
 };


Wrapped with SWIG 1.3.17 using -c++ and -shadow options to produce
files mymodule.py and _mymodule.pyd. If in Python I type:

import mymodule
h=mymodule.MyClass()
for i in range(10000):
    h.Mysend()

I get a crash (abnormal termination). For only 1000 loops it's ok. I
use Windows and Python 2.2.2.

SWIG interface file is
%module mymodule
%{
   #include "mymodule.h"
%}
%include mymodule.h


Does any have any ideas or know a work-around?

Andrew.




More information about the Python-list mailing list