[C++-sig] ownership of C++ object extended in Python

Tiago Coutinho coutinhotiago at gmail.com
Thu Dec 20 11:53:03 CET 2012


Hello all,

I want to export a class 'A' from an external library to python.
In python I need to extend the class and I need to tell the library that it
will 'own' the object.

I have tried the example in:

http://wiki.python.org/moin/boost.python/HowTo

(chapter "ownership of C++ object")

And executing the code I send in attachment I get:

$ python test1.py

Traceback (most recent call last):
  File "test1.py", line 19, in <module>
    main()
  File "test1.py", line 15, in main
    print(a.get_int())
Boost.Python.ArgumentError: Python argument types in
    A.get_int(B)
did not match C++ signature:
    get_int(A {lvalue})

Can you tell me what I am missing in the code?

Thank you in advance

PS: Sorry quality of the Makefile.

Regards
Tiago
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121220/0865d389/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 484 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121220/0865d389/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.cpp
Type: text/x-c++src
Size: 915 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121220/0865d389/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.py
Type: application/octet-stream
Size: 192 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121220/0865d389/attachment-0001.obj>


More information about the Cplusplus-sig mailing list