<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 3e405b6fd5db5615bbef241763de070118222ca7 Mon Sep 17 00:00:00 2001
From: Stefan Seefeld &lt;stefan@seefeld.name&gt;
Date: Thu, 9 Apr 2015 08:57:08 -0400
Subject: [PATCH] Fix exec_file for Python 3 &lt; 3.4.

---
 src/exec.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libs/python/src/exec.cpp b/libs/python/src/exec.cpp
index 2910db7..12cdabc 100644
--- a/libs/python/src/exec.cpp
+++ b/libs/python/src/exec.cpp
@@ -86,9 +86,12 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
   char *f = python::extract&lt;char *&gt;(filename);
 
   // Let python open the file to avoid potential binary incompatibilities.
-#if PY_VERSION_HEX &gt;= 0x03000000
-  // See http://www.codeproject.com/Articles/820116/Embedding-Python-program-in-a-C-Cplusplus-code
+#if PY_VERSION_HEX &gt;= 0x03400000
   FILE *fs = _Py_fopen(f, "r");
+#elif PY_VERSION_HEX &gt;= 0x03000000
+  PyObject *fo = Py_BuildValue("s", f);
+  FILE *fs = _Py_fopen(fo, "r");
+  Py_DECREF(fo);
 #else
   PyObject *pyfile = PyFile_FromString(f, const_cast&lt;char*&gt;("r"));
   if (!pyfile) throw std::invalid_argument(std::string(f) + " : no such file");
</pre></body></html>