From 7bfdb6f5bf3d26916d17de8025678e276b928fbb Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 21 Oct 2019 13:06:08 +0200 Subject: [PATCH] build: avoid bare exceptions in xcode_emulation.py https://realpython.com/the-most-diabolical-python-antipattern/ PR-URL: https://github.com/nodejs/node-gyp/pull/1932 Reviewed-By: Rod Vagg --- gyp/pylib/gyp/xcode_emulation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gyp/pylib/gyp/xcode_emulation.py b/gyp/pylib/gyp/xcode_emulation.py index 74735c033a..13964beec6 100644 --- a/gyp/pylib/gyp/xcode_emulation.py +++ b/gyp/pylib/gyp/xcode_emulation.py @@ -437,7 +437,7 @@ def _GetSdkVersionInfoItem(self, sdk, infoitem): # most sensible route and should still do the right thing. try: return GetStdoutQuiet(['xcodebuild', '-version', '-sdk', sdk, infoitem]) - except: + except GypError: pass def _SdkRoot(self, configname): @@ -1135,7 +1135,7 @@ def _DefaultSdkRoot(self): return default_sdk_root try: all_sdks = GetStdout(['xcodebuild', '-showsdks']) - except: + except GypError: # If xcodebuild fails, there will be no valid SDKs return '' for line in all_sdks.splitlines(): @@ -1276,7 +1276,7 @@ def XcodeVersion(): # checking that version. if len(version_list) < 2: raise GypError("xcodebuild returned unexpected results") - except: + except GypError: version = CLTVersion() if version: version = ".".join(version.split(".")[:3]) @@ -1314,7 +1314,7 @@ def CLTVersion(): try: output = GetStdout(['/usr/sbin/pkgutil', '--pkg-info', key]) return re.search(regex, output).groupdict()['version'] - except: + except GypError: continue