[C++-sig] Tutorial example for derivation in python doesn't work

Andreas Kloeckner ak at ixion.net
Wed Mar 10 13:52:53 CET 2004


Hi all,

I've tried to use python-implemented C++ interfaces as described in the
tutorial, with no luck. 

More specifically, I tried to just redo the example described in the
tutorial pages "Class Virtual Functions" and "Deriving a Python Class".
I copied-and-pasted  the examples there into two files (which you can
find attached to this email, along with my build script), built them,
and voila, I get the following error message:

Traceback (most recent call last):
  File "virtual_functions.py", line 7, in ?
      print call_f(Derived())
RuntimeError: This class cannot be instantiated from Python

Upon giving the derived class an __init__ function as commented out
below, the error changes to:

Traceback (most recent call last):
  File "virtual_functions.py", line 9, in ?
    print call_f(Derived())
Boost.Python.ArgumentError: Python argument types in
  virtual_functions_ext.call_f(Derived)
did not match C++ signature:
  call_f(Base {lvalue})

My configuration is
  Boost 1.31.0
  Python 2.3.3
  gcc 3.3.3

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virtual_functions.cpp
Type: text/x-c++src
Size: 458 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040310/6de7b98f/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virtual_functions.py
Type: application/x-python
Size: 145 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040310/6de7b98f/attachment.bin>
-------------- next part --------------
#!/bin/bash
g++-3.3 -shared -I$HOME/pool/include/python2.3 -I$HOME/work/boost $1.cpp -o $1_ext.so -lboost_python



More information about the Cplusplus-sig mailing list