Skip to content

Commit

Permalink
Fixed parsing the output of vswhere
Browse files Browse the repository at this point in the history
The output of vswhere uses "Ansi" encoding.
It was though decoded via "Utf-8", which raised
an exception in certain cases (i.e. letters like 'ö').

Thus, some visual studio installation could not be found.

Fixes #13281
  • Loading branch information
rainman110 committed Mar 1, 2023
1 parent a52c24b commit 80cd0bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conans/client/conf/detect_vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def vswhere(all_=False, prerelease=False, products=None, requires=None, version=
try:
from conans.util.runners import check_output_runner
cmd = cmd_args_to_string(arguments)
output = check_output_runner(cmd).strip()
output = check_output_runner(cmd, encoding="ansi").strip()
# Ignore the "description" field, that even decoded contains non valid charsets for json
# (ignored ones)
output = "\n".join([line for line in output.splitlines()
Expand Down
4 changes: 2 additions & 2 deletions conans/util/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def detect_runner(command):
return proc.returncode, "".join(output_buffer)


def check_output_runner(cmd, stderr=None):
def check_output_runner(cmd, stderr=None, encoding="utf-8"):
# Used to run several utilities, like Pacman detect, AIX version, uname, SCM
assert isinstance(cmd, str)
d = tempfile.mkdtemp()
Expand All @@ -96,7 +96,7 @@ def check_output_runner(cmd, stderr=None):
msg = f"Command '{cmd}' failed with errorcode '{process.returncode}'\n{stderr}"
raise ConanException(msg)

output = load(tmp_file)
output = load(tmp_file, encoding=encoding)
return output
finally:
try:
Expand Down

0 comments on commit 80cd0bc

Please sign in to comment.