[C++-sig] Re: boost:python:embedding
dirk at gerrits.homeip.net
Sat May 3 18:46:24 CEST 2003
Dirk Gerrits wrote:
> Dirk Gerrits wrote:
>> ... but I personally use a home-made
>> boost::python::interpreter class. (See attachments.) I would really
>> love to see it in Boost.Python but perhaps it is not "up to Boost
>> standards" at this point?
> Hmm, a bit of an understatement. The execfile code is giving me access
> violations. I'll look into it.
Okay, this seems to fix it:
void interpreter::execfile(char const* filename, dict& globals, dict&
FILE* file = 0;
handle<> py_file(allow_null( PyFile_FromString(filename, "r") ));
file = PyFile_AsFile(py_file.get());
throw std::runtime_error("Failed to open file: " +
PyRun_File(file, filename, Py_file_input, globals.ptr(),
Apparently, my C library is incompatible with the one my Python
installation was built with.
Anyway, it would be nice if this sort of low-level stuff was a part of
Boost.Python, so that I wouldn't have to make a fool of myself by
getting it wrong and posting about it. ;)
More information about the Cplusplus-sig