2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 05:42:30 +00:00

boost/python, libs/python: all changes from trunk merged into branches/release

[SVN r56806]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2009-10-13 22:37:59 +00:00
parent 46be73387c
commit 89100353db
52 changed files with 720 additions and 245 deletions

View File

@@ -88,11 +88,19 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
if (local.ptr() == none.ptr()) local = global;
// should be 'char const *' but older python versions don't use 'const' yet.
char *f = python::extract<char *>(filename);
#if PY_VERSION_HEX >= 0x03000000
// TODO(bhy) temporary workaround for Python 3.
// should figure out a way to avoid binary incompatibilities as the Python 2
// version did.
FILE *fs = fopen(f, "r");
#else
// Let python open the file to avoid potential binary incompatibilities.
PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r"));
if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file");
python::handle<> file(pyfile);
PyObject* result = PyRun_File(PyFile_AsFile(file.get()),
FILE *fs = PyFile_AsFile(file.get());
#endif
PyObject* result = PyRun_File(fs,
f,
Py_file_input,
global.ptr(), local.ptr());