Skip to content

Patching Boost 1.66 for Python 3.7

François Beaune edited this page Jan 15, 2019 · 3 revisions

Patching Boost 1.66 for Python 3.7

Boost 1.66 does not compile with Python 3.7 out of the box. In order to do so, you must patch one of the Boost.python files before compiling.

Download the patch and apply it with patch -p0 < boost_166_py37.patch.

Content of the patch:

--- a/converter/builtin_converters.cpp
+++ b/converter/builtin_converters.cpp
@@ -38,13 +38,18 @@ void shared_ptr_deleter::operator()(void const*)
 namespace
 {
 
-  // An lvalue conversion function which extracts a char const* from a
+   // An lvalue conversion function which extracts a char const* from a
   // Python String.
 #if PY_VERSION_HEX < 0x03000000
   void* convert_to_cstring(PyObject* obj)
   {
       return PyString_Check(obj) ? PyString_AsString(obj) : 0;
   }
+#elif PY_VERSION_HEX < 0x03070000
+  void* convert_to_cstring(PyObject* obj)
+  {
+      return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
+  }
 #else
   void* convert_to_cstring(PyObject* obj)
   {
Clone this wiki locally