-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SCons: Fix MSVC decode error #97618
SCons: Fix MSVC decode error #97618
Conversation
methods.py
Outdated
@@ -808,7 +808,7 @@ def get_compiler_version(env): | |||
if env.msvc and not using_clang(env): | |||
try: | |||
args = [env["VSWHERE"], "-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"] | |||
version = subprocess.check_output(args, encoding="utf-8").strip() | |||
version = subprocess.check_output(args, encoding=sys.stdout.encoding).strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version = subprocess.check_output(args, encoding=sys.stdout.encoding).strip() | |
version = subprocess.check_output(args, encoding="cp850").strip() |
Using sys.stdout.encoding does not work for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try errors="replace"
then; I'd rather not shuffle encoding up further if I can help it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encoding="oem" works too :)
Just for reference, the reason why this is happening is that vswhere returns a localized description
(see output below).
For me it's the german umlaut ü
that's causing this error, so whether we ignore
or replace
doesn't make a difference.
Visual Studio Locator version 3.1.7+f39851e70f [query version 3.11.2133.16870]
Copyright (C) Microsoft Corporation. All rights reserved.
instanceId: d103bfb2
installDate: 07.11.2023 23:03:44
installationName: VisualStudio/17.11.4+35312.102
installationPath: C:\Program Files\Microsoft Visual Studio\2022\Community
installationVersion: 17.11.35312.102
productId: Microsoft.VisualStudio.Product.Community
productPath: C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe
state: 4294967295
isComplete: 1
isLaunchable: 1
isPrerelease: 0
isRebootRequired: 0
displayName: Visual Studio Community 2022
description: Leistungsstarke IDE, kostenlos f�r Studenten, Open-Source-Mitwirkende und Einzelpersonen
channelId: VisualStudio.17.Release
channelUri: https://aka.ms/vs/17/release/channel
enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service
installedChannelId: VisualStudio.17.Release
installedChannelUri: https://aka.ms/vs/17/release/channel
releaseNotes: https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.11#17.11.4
resolvedInstallationPath: C:\Program Files\Microsoft Visual Studio\2022\Community
thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=661288
updateDate: 2024-09-23T11:09:33.850726Z
catalog_buildBranch: d17.11
catalog_buildVersion: 17.11.35312.102
catalog_id: VisualStudio/17.11.4+35312.102
catalog_localBuild: build-lab
catalog_manifestName: VisualStudio
catalog_manifestType: installer
catalog_productDisplayVersion: 17.11.4
catalog_productLine: Dev17
catalog_productLineVersion: 2022
catalog_productMilestone: RTW
catalog_productMilestoneIsPreRelease: False
catalog_productName: Visual Studio
catalog_productPatchVersion: 4
catalog_productPreReleaseMilestoneSuffix: 1.0
catalog_productSemanticVersion: 17.11.4+35312.102
catalog_requiredEngineVersion: 3.11.2180.21897
properties_campaignId: 2000
properties_channelManifestId: VisualStudio.17.Release/17.11.4+35312.102
properties_nickname:
properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe
437ff78
to
be34bd5
Compare
@matheusmdx To be clear you tested the latest version with |
I cherry-picked the commit 437ff780c5cb3461131a23ae0f973a543b09a7d5 |
methods.py
Outdated
@@ -808,7 +808,7 @@ def get_compiler_version(env): | |||
if env.msvc and not using_clang(env): | |||
try: | |||
args = [env["VSWHERE"], "-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args = [env["VSWHERE"], "-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"] | |
args = [env["VSWHERE"], "-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild", "-utf8"] |
Turns out you can just do this :)
https://github.com/microsoft/vswhere/wiki/Encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Well, that makes things easier
be34bd5 Also works |
be34bd5
to
9a8fcd5
Compare
Thanks! |
I'm not positive why a unicode decode error is occuring, but I'm fairly confident that recognizing the initial encoding as
sys.stdout.encoding
would fix it. Otherwise, the decode process might have to happen later.