summaryrefslogtreecommitdiff
path: root/libs/python
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-08 03:09:47 +0000
committer <>2015-05-05 14:37:32 +0000
commitf2541bb90af059680aa7036f315f052175999355 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /libs/python
parented232fdd34968697a68783b3195b1da4226915b5 (diff)
downloadboost-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/python')
-rw-r--r--libs/python/meta/libraries.json15
-rw-r--r--libs/python/src/exec.cpp16
2 files changed, 24 insertions, 7 deletions
diff --git a/libs/python/meta/libraries.json b/libs/python/meta/libraries.json
new file mode 100644
index 000000000..9fdb065db
--- /dev/null
+++ b/libs/python/meta/libraries.json
@@ -0,0 +1,15 @@
+{
+ "key": "python",
+ "name": "Python",
+ "authors": [
+ "Dave Abrahams"
+ ],
+ "description": "The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler.",
+ "category": [
+ "Inter-language"
+ ],
+ "maintainers": [
+ "Ralf Grosse-Kunstleve <rwgrosse-kunstleve -at- lbl.gov>",
+ "Ravi Rajagopal <lists_ravi -at- lavabit.com>"
+ ]
+}
diff --git a/libs/python/src/exec.cpp b/libs/python/src/exec.cpp
index 9fe1b23b7..2910db7c8 100644
--- a/libs/python/src/exec.cpp
+++ b/libs/python/src/exec.cpp
@@ -84,22 +84,24 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
if (local.is_none()) local = global;
// should be 'char const *' but older python versions don't use 'const' yet.
char *f = python::extract<char *>(filename);
+
+ // Let python open the file to avoid potential binary incompatibilities.
#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");
+ // See http://www.codeproject.com/Articles/820116/Embedding-Python-program-in-a-C-Cplusplus-code
+ FILE *fs = _Py_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);
FILE *fs = PyFile_AsFile(file.get());
#endif
- PyObject* result = PyRun_File(fs,
+
+ int closeit = 1; // Close file before PyRun returns
+ PyObject* result = PyRun_FileEx(fs,
f,
Py_file_input,
- global.ptr(), local.ptr());
+ global.ptr(), local.ptr(),
+ closeit);
if (!result) throw_error_already_set();
return object(detail::new_reference(result));
}