-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1e9eb3
commit 3e405b6
Showing
1 changed file
with
5 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,9 +86,12 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) | |
char *f = python::extract<char *>(filename); | ||
|
||
// Let python open the file to avoid potential binary incompatibilities. | ||
#if PY_VERSION_HEX >= 0x03000000 | ||
// See http://www.codeproject.com/Articles/820116/Embedding-Python-program-in-a-C-Cplusplus-code | ||
#if PY_VERSION_HEX >= 0x03400000 | ||
This comment has been minimized.
Sorry, something went wrong. |
||
FILE *fs = _Py_fopen(f, "r"); | ||
#elif PY_VERSION_HEX >= 0x03000000 | ||
PyObject *fo = Py_BuildValue("s", f); | ||
FILE *fs = _Py_fopen(fo, "r"); | ||
This comment has been minimized.
Sorry, something went wrong.
mmatrosov
Contributor
|
||
Py_DECREF(fo); | ||
#else | ||
PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r")); | ||
if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file"); | ||
|
1 comment
on commit 3e405b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefanseefeld Thank you for the fix! I did not think it would require special treatment for Python 3 < 3.4 and did not check it.
This version check is incorrect, it should be
#if PY_VERSION_HEX >= 0x03040000
.