Skip to content
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

Merged
merged 1 commit into from
Sep 29, 2024
Merged

Conversation

Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Sep 29, 2024

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.

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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

Copy link
Member

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

@akien-mga
Copy link
Member

@matheusmdx To be clear you tested the latest version with errors="replace"?

@matheusmdx
Copy link
Contributor

I cherry-picked the commit 437ff78

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"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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

@matheusmdx
Copy link
Contributor

be34bd5 Also works

@akien-mga akien-mga merged commit 72cff2e into godotengine:master Sep 29, 2024
19 checks passed
@akien-mga
Copy link
Member

Thanks!

@Repiteo Repiteo deleted the scons/decode-fix branch September 29, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scons throws UnicodeDecodeError when using MSVC
4 participants