Skip to content

Commit 9b37d94

Browse files
authored
Rollup merge of #71964 - jcotton42:bootstrap_decode_none_windows, r=Mark-Simulacrum
Fix bootstrap failing on win32 ```powershell python x.py -h # or really any x.py command ``` would fail with ``` info: Downloading and building bootstrap before processing --help command. See src/bootstrap/README.md for help with common commands. Updating only changed submodules Submodules updated in 0.15 seconds Traceback (most recent call last): File "x.py", line 11, in <module> bootstrap.main() File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 960, in main bootstrap(help_triggered) File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 925, in bootstrap build.build = args.build or build.build_triple() File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 731, in build_triple return default_build_triple() File "C:\Users\Joshua\Projects\forks\rust\src\bootstrap\bootstrap.py", line 184, in default_build_triple ostype = require(["uname", "-s"], exit=required).decode(default_encoding) AttributeError: 'NoneType' object has no attribute 'decode' ``` This PR defers the `decode` call until after we're sure `ostype` and `cputype` are not `None`, as they would be on Windows since `uname` doesn't exist
2 parents 1609451 + 7204fe4 commit 9b37d94

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/bootstrap/bootstrap.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ def format_build_time(duration):
180180
def default_build_triple():
181181
"""Build triple as in LLVM"""
182182
default_encoding = sys.getdefaultencoding()
183-
required = not sys.platform == 'win32'
184-
ostype = require(["uname", "-s"], exit=required).decode(default_encoding)
185-
cputype = require(['uname', '-m'], exit=required).decode(default_encoding)
183+
required = sys.platform != 'win32'
184+
ostype = require(["uname", "-s"], exit=required)
185+
cputype = require(['uname', '-m'], exit=required)
186186

187187
if ostype is None or cputype is None:
188188
return 'x86_64-pc-windows-msvc'
189+
190+
ostype = ostype.decode(default_encoding)
191+
cputype = cputype.decode(default_encoding)
189192

190193
# The goal here is to come up with the same triple as LLVM would,
191194
# at least for the subset of platforms we're willing to target.

0 commit comments

Comments
 (0)