Skip to content

Commit de4b36f

Browse files
tzikdschuff
authored andcommitted
Fix flake8 failures in scripts/ (#1239)
flake8 starts warning on bare "except:" in python scripts, and all CI job is failing for that.
1 parent a26b8ce commit de4b36f

6 files changed

Lines changed: 25 additions & 19 deletions

File tree

scripts/fuzz_passes.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def simplify(passes):
105105
try:
106106
apply_passes(smaller)
107107
assert run() == normal
108-
except:
108+
except Exception:
109109
# this failed too, so it's a good reduction
110110
passes = smaller
111111
print '>>> reduction successful'

scripts/fuzz_passes_wast.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def simplify(passes):
9696
try:
9797
apply_passes(smaller)
9898
assert run() == normal
99-
except:
99+
except Exception:
100100
# this failed too, so it's a good reduction
101101
passes = smaller
102102
print '>>> reduction successful'

scripts/fuzz_relooper.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
'fuzz.c']:
5757
try:
5858
os.unlink(temp)
59-
except:
59+
except OSError:
6060
pass
6161

6262
# parts

scripts/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def download_revision(force_latest):
3131
info = None
3232
try:
3333
info = json.loads(downloaded)
34-
except:
34+
except ValueError:
3535
pass
3636
return info['build'] if type(info) == dict else downloaded
3737

scripts/test/shared.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def setup_waterfall():
240240
subprocess.check_call([CLANG, '-v'])
241241
has_vanilla_llvm = True
242242
print '...success'
243-
except Exception, e:
243+
except (OSError, subprocess.CalledProcessError) as e:
244244
warn('could not run vanilla LLVM from waterfall: ' + str(e) +
245245
', looked for clang at ' + CLANG)
246246

@@ -256,25 +256,31 @@ def setup_waterfall():
256256
# external tools
257257

258258
try:
259-
subprocess.check_call(
260-
[NODEJS, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
261-
except:
259+
if NODEJS is not None:
260+
subprocess.check_call(
261+
[NODEJS, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
262+
except (OSError, subprocess.CalledProcessError):
262263
NODEJS = None
264+
if NODEJS is None:
263265
warn('no node found (did not check proper js form)')
264266

265267
try:
266-
subprocess.check_call(
267-
[MOZJS, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
268-
except:
268+
if MOZJS is not None:
269+
subprocess.check_call(
270+
[MOZJS, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
271+
except (OSError, subprocess.CalledProcessError):
269272
MOZJS = None
273+
if MOZJS is None:
270274
warn('no mozjs found (did not check native wasm support nor asm.js'
271275
' validation)')
272276

273277
try:
274-
subprocess.check_call(
275-
[EMCC, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
276-
except:
278+
if EMCC is not None:
279+
subprocess.check_call(
280+
[EMCC, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
281+
except (OSError, subprocess.CalledProcessError):
277282
EMCC = None
283+
if EMCC is None:
278284
warn('no emcc found (did not check non-vanilla emscripten/binaryen'
279285
' integration)')
280286

@@ -284,7 +290,7 @@ def setup_waterfall():
284290
[os.path.join(options.binaryen_test, 'emscripten', 'emcc'), '--version'],
285291
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
286292
has_vanilla_emcc = True
287-
except:
293+
except (OSError, subprocess.CalledProcessError):
288294
pass
289295

290296

@@ -294,13 +300,13 @@ def setup_waterfall():
294300
def delete_from_orbit(filename):
295301
try:
296302
os.unlink(filename)
297-
except:
303+
except OSError:
298304
pass
299305
if not os.path.exists(filename):
300306
return
301307
try:
302308
shutil.rmtree(filename, ignore_errors=True)
303-
except:
309+
except OSError:
304310
pass
305311
if not os.path.exists(filename):
306312
return
@@ -315,7 +321,7 @@ def remove_readonly_and_try_again(func, path, exc_info):
315321
else:
316322
raise
317323
shutil.rmtree(filename, onerror=remove_readonly_and_try_again)
318-
except:
324+
except OSError:
319325
pass
320326

321327

scripts/test/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _open_archive(tarfile, tmp_dir):
2626
with tempfile.TemporaryFile(mode='w+') as f:
2727
try:
2828
subprocess.check_call(['tar', '-xvf', tarfile], cwd=tmp_dir, stdout=f)
29-
except:
29+
except Exception:
3030
f.seek(0)
3131
sys.stderr.write(f.read())
3232
raise

0 commit comments

Comments
 (0)