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()`.
This commit is contained in:
Oliver Stöneberg 2023-12-15 12:34:32 +01:00 committed by GitHub
parent 42547aac9e
commit c79ec60bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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])) {