object constructor + integer == fail

View: New views
3 Messages — Rating Filter:   Alert me  

object constructor + integer == fail

by Daniel Löb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

I seem to be unable to call the constructor of "object" with an integer
parameter.
Working example:

#include <boost/python.hpp>
#include <iostream>

using namespace boost::python;
using std::cout;
using std::endl;

int main()
{
        object toast(3);
        cout << extract<int>(toast) << endl;
}

It compiles just fine, but dies with a segmentation fault on execution
of the first line within main.

Backtrace:

0x00007ffff7ac9ca3 in PyInt_FromLong () from /usr/lib/libpython2.5.so.1.0
#1  0x0000000000401860 in arg_to_python (this=0x7fffffffeb30,
x=@0x7fffffffebdc) at
/usr/include/boost/python/converter/builtin_converters.hpp:113
#2  0x0000000000401888 in
boost::python::api::object_initializer_impl<false, false>::get<int>
(x=@0x7fffffffebdc)
     at /usr/include/boost/python/object_core.hpp:374
#3  0x00000000004018cb in
boost::python::api::object_base_initializer<int> (x=@0x7fffffffebdc) at
/usr/include/boost/python/object_core.hpp:296
#4  0x00000000004018e7 in object<int> (this=0x7fffffffebd0,
x=@0x7fffffffebdc) at /usr/include/boost/python/object_core.hpp:315
#5  0x0000000000401196 in main () at bp_bug.cpp:10

Doing the same as above with a string instead of an integer works fine.
I'm running debian with libboost-python1.38.0 .

Greetings,
Daniel
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: object constructor + integer == fail

by troy d. straszheim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel Löb wrote:

> Hi!
>
> I seem to be unable to call the constructor of "object" with an integer
> parameter.
> Working example:
>
> #include <boost/python.hpp>
> #include <iostream>
>
> using namespace boost::python;
> using std::cout;
> using std::endl;
>
> int main()
> {
>     object toast(3);
>     cout << extract<int>(toast) << endl;
> }
>
> It compiles just fine, but dies with a segmentation fault on execution
> of the first line within main.
>

Does calling Py_Initialize() help?

-t


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: object constructor + integer == fail

by Daniel Löb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

troy d. straszheim wrote:

> Daniel Löb wrote:
>> Hi!
>>
>> I seem to be unable to call the constructor of "object" with an
>> integer parameter.
>> Working example:
>>
>> #include <boost/python.hpp>
>> #include <iostream>
>>
>> using namespace boost::python;
>> using std::cout;
>> using std::endl;
>>
>> int main()
>> {
>>     object toast(3);
>>     cout << extract<int>(toast) << endl;
>> }
>>
>> It compiles just fine, but dies with a segmentation fault on execution
>> of the first line within main.
>>
>
> Does calling Py_Initialize() help?
>
Yes, that did it.

Thank you!

Best regards,
Daniel
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig