We have a set of c++ classes wrapped by swig for python. When importing one of these classes in python, we're getting the following error message:
File ".../myobjects.py", line 176, in <module>
class RT(_object):
File ".../myobjects.py", line 187, in RT
\__swig_destroy__ = _myobjects.delete_RT
AttributeError: 'module' object has no attribute 'delete_RT'
myobjects.py swig generated code of RT looks like this:
class RT(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, RT, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, RT, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _myobjects.new_RT(*args)
try: self.this.append(this)
except: self.this = this
def getName(self): return _myobjects.RT_getName(self)
__swig_destroy__ = _myobjects.delete_RT
__del__ = lambda self : None;
And the cxx file from which _myobjects.so is created has the following lines:
SWIGINTERN PyObject *_wrap_delete_RT(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
RT *arg1 = (RT *) 0 ;
...
In short, all appears in order but we still get the python error.
Any ideas anyone?
Thanks,
Tomer
Well, not sure why this happened, but the Class just preceeding this one in the cxx file was included by two i files. Removing one inclusion fixed the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.