From fc39cf18e11f81a8d6f748b9b383f632343dab80 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 29 Oct 2020 11:15:04 +0100 Subject: [PATCH] Debugger: fix debugger in modified python environment We do not want to pick up any python environment variables for the cdbext python initialization which might change the module search path, because we already contain the needed python modules in the zip file next to the extension. Fixes: QTCREATORBUG-24859 Change-Id: I0d597f42042d249529309263d71b0e740e903a48 Reviewed-by: Christian Stenger --- src/libs/qtcreatorcdbext/CMakeLists.txt | 4 ++-- src/libs/qtcreatorcdbext/extensioncontext.cpp | 9 ++++++++- src/libs/qtcreatorcdbext/qtcreatorcdbext.pro | 2 +- src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs | 7 ++++--- src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index b6171d183dd..45d55474aad 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -45,9 +45,9 @@ add_qtc_library(qtcreatorcdbext qtc_library_enabled(_library_enabled qtcreatorcdbext) if (_library_enabled) - find_package(PythonLibs 3.5) + find_package(PythonLibs 3.8) if (NOT ${PYTHONLIBS_FOUND}) - message(WARNING "PythonLibs (at least version 3.5) not found. qtcreatorcdbext will be built without Python support.") + message(WARNING "PythonLibs (at least version 3.8) not found. qtcreatorcdbext will be built without Python support.") return() endif() diff --git a/src/libs/qtcreatorcdbext/extensioncontext.cpp b/src/libs/qtcreatorcdbext/extensioncontext.cpp index c6ae69fac7e..4842289c670 100644 --- a/src/libs/qtcreatorcdbext/extensioncontext.cpp +++ b/src/libs/qtcreatorcdbext/extensioncontext.cpp @@ -162,7 +162,14 @@ HRESULT ExtensionContext::initialize(PULONG Version, PULONG Flags) #ifdef WITH_PYTHON initCdbextPythonModule(); - Py_Initialize(); + PyStatus status; + PyConfig config; + PyConfig_InitIsolatedConfig(&config); + status = Py_InitializeFromConfig(&config); + PyConfig_Clear(&config); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } PyRun_SimpleString("import cdbext"); PyRun_SimpleString("import sys"); #endif diff --git a/src/libs/qtcreatorcdbext/qtcreatorcdbext.pro b/src/libs/qtcreatorcdbext/qtcreatorcdbext.pro index 98961887b94..f9f30f925f9 100644 --- a/src/libs/qtcreatorcdbext/qtcreatorcdbext.pro +++ b/src/libs/qtcreatorcdbext/qtcreatorcdbext.pro @@ -114,7 +114,7 @@ isEmpty(PYTHON_INSTALL_DIR):PYTHON_INSTALL_DIR=$$(PYTHON_INSTALL_DIR) CONFIG(debug, debug|release): deploy_python.recurse = Debug QMAKE_EXTRA_TARGETS += deploy_python } else { - message("Set PYTHON_INSTALL_DIR pointing to Python 3.5 or greater to enable the python dumpers for cdb.") + message("Set PYTHON_INSTALL_DIR pointing to Python 3.8 or greater to enable the python dumpers for cdb.") } target.path = $$QTC_PREFIX/lib/$${DIRNAME} # TODO this should go to INSTALL_LIBRARY_PATH/$${DIRNAME} diff --git a/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs b/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs index 3f446e2916f..fac2f7a25b7 100644 --- a/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs +++ b/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs @@ -50,10 +50,11 @@ QtcLibrary { + output + "'"); return; } - if (Utilities.versionCompare(versionNumberString, "3.5") < 0) { + var pythonMinVersion = "3.8"; + if (Utilities.versionCompare(versionNumberString, pythonMinVersion) < 0) { printWarning("The python installation at '" + pythonDir - + "' has version " + versionNumberString + ", but 3.5 or higher " - + "is required."); + + "' has version " + versionNumberString + ", but " + + pythonMinVersion + " or higher is required."); return; } found = true; diff --git a/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp b/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp index f4dcde9736c..4895fb6c2e5 100644 --- a/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp +++ b/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp @@ -654,7 +654,7 @@ extern "C" HRESULT CALLBACK script(CIDebugClient *client, PCSTR argsIn) ExtensionContext::instance().report('N', token, 0, "script", "Python is not supported in this CDB extension.\n" "You need to define PYTHON_INSTALL_DIR in your creator build environment " - "pointing to a Python 3.5 installation."); + "pointing to a Python 3.8 installation."); #endif return S_OK; }