[C++-sig] Problem With Calling Methods on Python Subclasses from C++

Mark Rowe lists.python.org at bdash.net.nz
Sun Oct 17 11:44:08 CEST 2004


Hi,

I am working on wrapping a C++ library using Boost::Python but have run 
into a small problem with polymorphic behaviour.

Basically, I have four classes exposed to Python - MainClass, 
ErrorHandler, Error and AnError.  AnError derives from Error.  When 
ErrorHandler is subclassed from Python and the handleError method of an 
instance of the Python subclass is called from C++ with an AnError 
instance as an argument, the argument arrives as an Error type.  I 
realise that this description is relatively confusing, so I have 
attached the C++ code and a failing Python unittest that demonstrates 
the problem I am encountering.

I hope that someone can clear this issue up for me.

Regards,

Mark Rowe
<http://bdash.net.nz/>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041017/eec66a15/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: application/octet-stream
Size: 599 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041017/eec66a15/attachment.obj>


More information about the Cplusplus-sig mailing list