From c79ec60bee1a226fd4cc84eda56b0a470e249529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 15 Dec 2023 12:34:32 +0100 Subject: [PATCH] fixed #12264 - auto-detection of Python in Visual Studio built binaries when `python3.exe` does not exist (#5765) I also suppressed the unwanted output from the `system()`. --- lib/cppcheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 2d772662d..ba2e4170c 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -226,10 +226,10 @@ static std::string detectPython(const CppCheck::ExecuteCmdFn &executeCommand) std::string out; #ifdef _MSC_VER // FIXME: hack to avoid debug assertion with _popen() in executeCommand() for non-existing commands - const std::string cmd = std::string(py_exe) + " --version >NUL"; + const std::string cmd = std::string(py_exe) + " --version >NUL 2>&1"; if (system(cmd.c_str()) != 0) { // TODO: get more detailed error? - break; + continue; } #endif if (executeCommand(py_exe, split("--version"), "2>&1", out) == EXIT_SUCCESS && startsWith(out, "Python ") && std::isdigit(out[7])) {