Fix bare 'except:' to placate errors in new flake8 version.

- fixes E722 errors from latest version of flake8
- requires us to not use 'bare except:' and catch BaseException instead
This commit is contained in:
Todd Gamblin
2017-10-23 16:51:11 +02:00
parent b98fc48273
commit 5449884b2e
17 changed files with 27 additions and 27 deletions

View File

@@ -130,7 +130,7 @@ def groupid_to_group(x):
try:
for line in fileinput.input(filename, inplace=True):
print(re.sub(regex, repl, line.rstrip('\n')))
except:
except BaseException:
# clean up the original file on failure.
shutil.move(backup_filename, filename)
raise

View File

@@ -250,7 +250,7 @@ def ioctl_GWINSZ(fd):
try:
rc = struct.unpack('hh', fcntl.ioctl(
fd, termios.TIOCGWINSZ, '1234'))
except:
except BaseException:
return
return rc
rc = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
@@ -259,7 +259,7 @@ def ioctl_GWINSZ(fd):
fd = os.open(os.ctermid(), os.O_RDONLY)
rc = ioctl_GWINSZ(fd)
os.close(fd)
except:
except BaseException:
pass
if not rc:
rc = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))

View File

@@ -167,7 +167,7 @@ def colify(elts, **options):
r, c = env_size.split('x')
console_rows, console_cols = int(r), int(c)
tty = True
except:
except BaseException:
pass
# Use only one column if not a tty.

View File

@@ -166,7 +166,7 @@ def _file_descriptors_work(*streams):
for stream in streams:
stream.fileno()
return True
except:
except BaseException:
return False
@@ -310,7 +310,7 @@ def __enter__(self):
# need to pass this b/c multiprocessing closes stdin in child.
try:
input_stream = os.fdopen(os.dup(sys.stdin.fileno()))
except:
except BaseException:
input_stream = None # just don't forward input if this fails
self.process = multiprocessing.Process(
@@ -483,7 +483,7 @@ def _writer_daemon(self, stdin):
force_echo = True
if xoff in controls:
force_echo = False
except:
except BaseException:
tty.error("Exception occurred in writer daemon!")
traceback.print_exc()