[C++-sig] Re: Documentation error or too much newbie?
yakumoklesk at yahoo.es
yakumoklesk at yahoo.es
Sun Sep 14 12:20:42 CEST 2003
I made a chekout from soundforge, compiled the boost libraries, then
compiled de C program, and got an error because
boost\python\detail\member_function_cast.hpp was not found. CVS did
not retrieved it.
I made a checkout from boost-consulting in other directory, compiled
again the boost libraries and then compiled the C++ program without
any errors. But when it is going to convert the handle into a dict object,
it results in an acces violation again.
What I am doing bad? Do I have to download python 2.3 instead of
using python 2.2.3 in debug mode?(python_d.lib).
I'll try the release version of the libraries and DLLs to see what
happens.
David Lucena.
On 13 Sep 2003 at 23:40, Dirk Gerrits wrote:
> yakumoklesk at yahoo.es wrote:
> > Opps, sorry. In the documentation there is written
> >
> > main_namespace dict(...)
> >
> > I think it is
> >
> > dict main_namespace(...), because dict is an boost.python object
> > representing a python dict, isn't it?
>
> Yes, a very embarassing mistake on my part. But the fix you suggested
> has been in CVS for quite some time. Even before the 1.30.1 release I
> believe. That it's not in 1.30.1 or 1.30.2 is perhaps due to my negligance?
>
> > But the fact is that
> >
> > dict main_namespace( handle<>( borrowed( PyModule_GetDict(
> > main_module.get() ) ) );
> >
> > gives me an acces violation whet it is executed. Of course, before this
> > line is executed first I initialize the pyton interpreter with Py_Initialize()
> > and then I add the main module (if it isn't added yet) using the line (as
> > shown in documentation)
> >
> > handle<> main_module(borrowed(
> > PyImport_AddModule("__main__") ));
> >
> > So, what have I forgot to do? How can I avoid the ACCES VIOLATION
> > given by the execution of the "dict main_namespace(..)" statement?
>
> I just tried the following out on MSVC7.1 with Python 2.3 and a Boost
> from CVS, though I think it's a few weeks old now. (Better do a CVS
> update. :)) It worked for me, so I assume you are using a different
> compiler and/or different versions of Python and Boost.Python. Some more
> information would help...
>
> #include <iostream>
> #include <boost/python.hpp>
>
> using namespace boost::python;
>
> int main()
> {
> Py_Initialize();
> handle<> main_module(borrowed( PyImport_AddModule("__main__") ));
> dict main_namespace(handle<>(borrowed(
> PyModule_GetDict(main_module.get()) )));
> handle<>( PyRun_String("result = 5 ** 2", Py_file_input,
> main_namespace.ptr(), main_namespace.ptr()) );
> int five_squared = extract<int>( main_namespace["result"] );
> std::cout << "5^2 = " << five_squared << "\n";
> Py_Finalize();
> }
>
> Regards,
> Dirk Gerrits
>
>
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
More information about the Cplusplus-sig
mailing list