[PyQt] SIP: deriving a python class from a C++ ABC results in a TypeError exception
Demetrius Cassidy
dcassidy36 at gmail.com
Sat Jul 2 18:39:14 BST 2011
I have a C++ class which is declared with pure virtual methods, but if I
derive from this class in python and implement the pure virtual methods, I
get an exception:
TypeError: pyvoip.opal.OpalPCSSEndPoint cannot be instantiated or
sub-classed
My python class is declared as following:
class PCSSEndPoint(OpalPCSSEndPoint):
def __init__(self):
super(OpalPCSSEndPoint, self).__init__()
def OnShowIncoming(self, connection):
return True
def OnShowOutgoing(self, connection):
return True
def GetMediaFormats(self):
return []
SIP definitions:
class OpalPCSSEndPoint : OpalLocalEndPoint /Abstract/
{
/**Call back to indicate that remote is ringing.
If false is returned the call is aborted.
The default implementation is pure.
*/
virtual PBoolean OnShowIncoming(
const OpalPCSSConnection & connection /NoCopy/ ///< Connection having event
) = 0;
/**Call back to indicate that remote is ringing.
If false is returned the call is aborted.
The default implementation is pure.
*/
virtual PBoolean OnShowOutgoing(
const OpalPCSSConnection & connection /NoCopy/ ///< Connection having event
) = 0;
};
Now the base class of OpalPCSSEndPoint is also an ABC, as it derives from an
ABC but does not re-define the pure virtual function:
class OpalLocalEndPoint : OpalEndPoint /Abstract/
{
...
};
class OpalEndPoint /Abstract/
{
virtual OpalMediaFormatList GetMediaFormats() const = 0;
};
I tried removing /Abstract/ from OpalLocalEndPoint, but it made no
difference. Any idea what's wrong in this scenario? The only way this
works, is if I subclass OpalPCSSEndPoint in C++ and then in Python create a
class derived from my OpalPCSSEndPoint subclass.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110702/089ea221/attachment.html>
More information about the PyQt
mailing list