GeezerVison is showing github.com — Fix compilation with python 3.0-3.3 · mborgerding/python@36f8f69
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/exec.cpp +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -84,11 +84,12 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local) |
84 | 84 | if (local.is_none()) local = global; |
85 | 85 | // should be 'char const *' but older python versions don't use 'const' yet. |
86 | 86 | char *f = python::extract<char *>(filename); |
87 | | -#if PY_VERSION_HEX >= 0x03000000 |
88 | | - // TODO(bhy) temporary workaround for Python 3. |
89 | | - // should figure out a way to avoid binary incompatibilities as the Python 2 |
90 | | - // version did. |
| 87 | +#if PY_VERSION_HEX >= 0x03040000 |
91 | 88 | FILE *fs = fopen(f, "r"); |
| 89 | +#elif PY_VERSION_HEX >= 0x03000000 |
| 90 | + PyObject *fo = Py_BuildValue("s", f); |
| 91 | + FILE *fs = _Py_fopen(fo, "r"); |
| 92 | + Py_DECREF(fo); |
92 | 93 | #else |
93 | 94 | // Let python open the file to avoid potential binary incompatibilities. |
94 | 95 | PyObject *pyfile = PyFile_FromString(f, const_cast<char*>("r")); |
|