From 34c11fcc63efa2fc72cbc74c75c76e9f19d5c84c Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 4 Sep 2020 19:02:29 +0200 Subject: [PATCH] Base: Py2 related fix --- src/Base/Interpreter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 44c4b35a0a..321b2cc856 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -328,8 +328,12 @@ std::string InterpreterSingleton::runStringWithKey(const char *psCmd, const char if (!key_return_value.isString()) key_return_value = key_return_value.str(); +#if PY_MAJOR_VERSION >= 3 Py::Bytes str = Py::String(key_return_value).encode("utf-8", "~E~"); std::string result = static_cast(str); +#else + std::string result = static_cast(Py::String(key_return_value)); +#endif return result; }