[C++-sig] Re: boost:python:embedding

David Abrahams dave at boost-consulting.com
Sat May 3 22:46:32 CEST 2003


Dirk Gerrits <dirk at gerrits.homeip.net> writes:

> Okay, this seems to fix it:
>
> void interpreter::execfile(char const* filename, dict& globals, dict&
> locals)
> {
>      FILE* file = 0;
>
>      handle<> py_file(allow_null( PyFile_FromString(filename, "r") ));
>      if (py_file)
>          file = PyFile_AsFile(py_file.get());
>      if (!file)
>          throw std::runtime_error("Failed to open file: " +
>          std::string(filename));
>      handle<> result(
>          PyRun_File(file, filename, Py_file_input, globals.ptr(),
>          locals.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. ;)

How do you think it's going to get into the library anyway, Dirk?
You're going to have to submit your code, along with documentation and
tests.  I'll certainly credit you in the acknowledgements page and
your name will go in the copyrights for that code so credit (or blame)
will still be on you! ;-)

Anyway, I'd be delighted to have this in Boost.Python, so long as it
comes with docs and tests.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list