X Tutup
Skip to content

Commit 65a17cf

Browse files
committed
Use except Foo as e consistently
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 4cd6684 commit 65a17cf

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

bpython/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def push(self, s, insert_into_history=True):
10771077
curses.raw(False)
10781078
try:
10791079
return repl.Repl.push(self, s, insert_into_history)
1080-
except SystemExit, e:
1080+
except SystemExit as e:
10811081
# Avoid a traceback on e.g. quit()
10821082
self.do_exit = True
10831083
self.exit_value = e.args
@@ -1895,7 +1895,7 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
18951895
exit_value = ()
18961896
try:
18971897
bpython.args.exec_code(interpreter, args)
1898-
except SystemExit, e:
1898+
except SystemExit as e:
18991899
# The documentation of code.InteractiveInterpreter.runcode claims
19001900
# that it reraises SystemExit. However, I can't manage to trigger
19011901
# that. To be one the safe side let's catch SystemExit here anyway.

bpython/curtsies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def main(args=None, locals_=None, banner=None):
5858
try:
5959
interp = code.InteractiveInterpreter(locals=locals_)
6060
bpargs.exec_code(interp, exec_args)
61-
except SystemExit, e:
61+
except SystemExit as e:
6262
exit_value = e.args
6363
if not options.interactive:
6464
raise SystemExit(exit_value)

bpython/curtsiesfrontend/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ def pager(self, text):
13511351
def show_source(self):
13521352
try:
13531353
source = self.get_source_of_current_name()
1354-
except SourceNotFound, e:
1354+
except SourceNotFound as e:
13551355
self.status_bar.message(_(e))
13561356
else:
13571357
if self.config.highlight_show_source:

bpython/pager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,22 @@ def page(data, use_internal=False):
5454
data = data.encode(sys.__stdout__.encoding, 'replace')
5555
popen.stdin.write(data)
5656
popen.stdin.close()
57-
except OSError, e:
57+
except OSError as e:
5858
if e.errno == errno.ENOENT:
5959
# pager command not found, fall back to internal pager
6060
page_internal(data)
6161
return
62-
except IOError, e:
62+
except IOError as e:
6363
if e.errno != errno.EPIPE:
6464
raise
6565
while True:
6666
try:
6767
popen.wait()
68-
except OSError, e:
68+
except OSError as e:
6969
if e.errno != errno.EINTR:
7070
raise
7171
else:
7272
break
7373
curses.doupdate()
74+
75+
# vim: sw=4 ts=4 sts=4 ai et

bpython/repl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,11 @@ def get_source_of_current_name(self):
602602
if inspection.is_eval_safe_name(line):
603603
obj = self.get_object(line)
604604
return inspect.getsource(obj)
605-
except (AttributeError, NameError), e:
605+
except (AttributeError, NameError) as e:
606606
msg = "Cannot get source: " + str(e)
607-
except IOError, e:
607+
except IOError as e:
608608
msg = str(e)
609-
except TypeError, e:
609+
except TypeError as e:
610610
if "built-in" in str(e):
611611
msg = "Cannot access source of %r" % (obj, )
612612
else:
@@ -840,7 +840,7 @@ def do_pastebin_helper(self, s):
840840
helper.stdin.write(s.encode(getpreferredencoding()))
841841
output = helper.communicate()[0].decode(getpreferredencoding())
842842
paste_url = output.split()[0]
843-
except OSError, e:
843+
except OSError as e:
844844
if e.errno == errno.ENOENT:
845845
self.interact.notify(_('Upload failed: '
846846
'Helper program not found.'))
@@ -898,7 +898,7 @@ def insert_into_history(self, s):
898898
self.rl_history.append(s)
899899
try:
900900
self.rl_history.save(histfilename, getpreferredencoding(), self.config.hist_length)
901-
except EnvironmentError, err:
901+
except EnvironmentError as err:
902902
self.interact.notify("Error occured while writing to file %s (%s) " % (histfilename, err.strerror))
903903
self.rl_history.entries = oldhistory
904904
self.rl_history.append(s)

0 commit comments

Comments
 (0)
X Tutup