Skip to content

Commit b21ee31

Browse files
aduh95cclauss
andauthored
fix: handle None case in xcode_emulation regexes (#311)
Co-authored-by: Christian Clauss <[email protected]>
1 parent 94c13e0 commit b21ee31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pylib/gyp/xcode_emulation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,18 +1534,20 @@ def CLTVersion():
15341534
FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI"
15351535
MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables"
15361536

1537-
regex = re.compile("version: (?P<version>.+)")
1537+
regex = re.compile(r"version: (?P<version>.+)")
15381538
for key in [MAVERICKS_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID]:
15391539
try:
15401540
output = GetStdout(["/usr/sbin/pkgutil", "--pkg-info", key])
1541-
return re.search(regex, output).groupdict()["version"]
1541+
if m := re.search(regex, output):
1542+
return m.groupdict()["version"]
15421543
except (GypError, OSError):
15431544
continue
15441545

15451546
regex = re.compile(r"Command Line Tools for Xcode\s+(?P<version>\S+)")
15461547
try:
15471548
output = GetStdout(["/usr/sbin/softwareupdate", "--history"])
1548-
return re.search(regex, output).groupdict()["version"]
1549+
if m := re.search(regex, output):
1550+
return m.groupdict()["version"]
15491551
except (GypError, OSError):
15501552
return None
15511553

0 commit comments

Comments
 (0)