[C++-sig] Using .add_property with make_getter.

Kirsebom Nikolai nikolai.kirsebom at siemens.no
Tue Jun 24 11:53:17 CEST 2003

I have the following c++ class:
class PyDLEPRInterface : public DLEPRInterface
	PyDLEPRInterface(const PyDLEPRInterface& objectSrc);

PyDLEPRInterface::PyDLEPRInterface(const PyDLEPRInterface& objectSrc)


The class DLEPRInterface defines some public attributes, example
	CString m_DocumentCategory;
	int m_UserID;

I have a converter for converting CString <--> python string.
See code in thread "Exception second time loaded" 20th of June.

The two attributes are exposed with the statements:
	.def_readonly("UserID", &PyDLEPRInterface::m_UserID)

When running in Python, the UserID is available however reading the
DocumentCategory attribute produces the following traceback:

import DocuLive  #<<Module exposing function to get an existing
PyDELEPRInterface object
import CString #<<Module handling the conversion
v = DocuLive.getit() #<<Fetch the exisiting object
v.UserID #<<Print the value for UserID attribute
Traceback (most recent call last):
  File "<input>", line 1, in ?
TypeError: bad argument type for built-in operation

I'm running the python statements in a PyCrust (wxPython/wxWindows) shell
In my posting 20th of June I asked for help relating to exception when
staring the second time.  It appears that the starting of the mainloop in
the PyCrust application produces the exception if other applications (in
Windows) has been activated in between.  Have not found the reason for this
All help is appreciated.
Nikolai Kirsebom

More information about the Cplusplus-sig mailing list