[C++-sig] Re: Creating an instance of a Python class in C++: PyRun_String?

Dirk Gerrits dirk at gerrits.homeip.net
Thu Nov 14 23:00:39 CET 2002

Dirk Gerrits wrote:

> Firstly, I don't know which arguments to feed into PyRun_String. The
> python.org docs didn't really help me that much: I don't have any
> dictionaries of globals and locals, and what exactly is a start token? 

Upon further RTFMing on start tokens, I tried this:

// Create and use an instance of the Python derived class
Base* py = python::extract<Base*>(
     PyRun_String("PythonDerived()\n", Py_eval_input, 0, 0));

This gives an access violation in find_instance_impl which is called by 
extract_pointer<Ptr>::extract_pointer(PyObject* obj) as far as I can 
tell. And the Base& version wouldn't compile as I said.

What (else) am I doing wrong?


PS I forgot to mention that I'm using Intel C++ Compiler 6.0 on Windows 
2000 SP2 with Boost 1.29.0.

More information about the Cplusplus-sig mailing list