Skip to content

Commit

Permalink
fixed #12264 - auto-detection of Python in Visual Studio built binari…
Browse files Browse the repository at this point in the history
…es when `python3.exe` does not exist (#5765)

I also suppressed the unwanted output from the `system()`.
  • Loading branch information
firewave committed Dec 15, 2023
1 parent 42547aa commit c79ec60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down

0 comments on commit c79ec60

Please sign in to comment.