From e9384a9fc95b88ede3de997a0fb03729bb864cc5 Mon Sep 17 00:00:00 2001
From: Gerardo Tauriello <gerardo.tauriello@unibas.ch>
Date: Thu, 13 Dec 2018 18:45:33 +0100
Subject: [PATCH] Boost Python String conversion causes problems with Boost
 1.65.

Tested with Boost 1.53 on CentOS 7.5 so it still works with old Boost.
---
 modules/gui/src/python_shell/main_thread_runner.cc        | 3 ++-
 modules/gui/src/python_shell/python_interpreter_worker.cc | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/gui/src/python_shell/main_thread_runner.cc b/modules/gui/src/python_shell/main_thread_runner.cc
index 6b05ca64a..4dcb382da 100644
--- a/modules/gui/src/python_shell/main_thread_runner.cc
+++ b/modules/gui/src/python_shell/main_thread_runner.cc
@@ -37,7 +37,8 @@ void MainThreadRunner::Run(const QString& widget)
   PyGILState_STATE gstate = PyGILState_Ensure();
   bp::object  main_module = bp::import("__main__");
   bp::object main_namespace = main_module.attr("__dict__");
-  bp::exec(bp::str("Proxy._widget_=QtGui."+widget.toStdString()+"()\n"),main_namespace,main_namespace);
+  std::string cmd = "Proxy._widget_=QtGui." + widget.toStdString() + "()\n";
+  bp::exec(cmd.c_str(), main_namespace, main_namespace);
   PyGILState_Release(gstate);
 }
 
diff --git a/modules/gui/src/python_shell/python_interpreter_worker.cc b/modules/gui/src/python_shell/python_interpreter_worker.cc
index e75f48460..ed1dea231 100644
--- a/modules/gui/src/python_shell/python_interpreter_worker.cc
+++ b/modules/gui/src/python_shell/python_interpreter_worker.cc
@@ -126,7 +126,7 @@ void PythonInterpreterWorker::run_command_(std::pair<unsigned int,QString> pair)
         handle_redirector_output(QString::fromStdString(rstring)+"\n");
       }
     } else {
-      bp::exec(bp::str(command.toStdString()),main_namespace_,main_namespace_);
+      bp::exec(command.toStdString().c_str(), main_namespace_, main_namespace_);
     }
     output_redirector_->Flush();
     error_redirector_->Flush();
-- 
GitLab