Show More
@@ -163,19 +163,19 class Config(dict): | |||
|
163 | 163 | def __getattr__(self, key): |
|
164 | 164 | try: |
|
165 | 165 | return self.__getitem__(key) |
|
166 |
except KeyError |
|
|
166 | except KeyError as e: | |
|
167 | 167 | raise AttributeError(e) |
|
168 | 168 | |
|
169 | 169 | def __setattr__(self, key, value): |
|
170 | 170 | try: |
|
171 | 171 | self.__setitem__(key, value) |
|
172 |
except KeyError |
|
|
172 | except KeyError as e: | |
|
173 | 173 | raise AttributeError(e) |
|
174 | 174 | |
|
175 | 175 | def __delattr__(self, key): |
|
176 | 176 | try: |
|
177 | 177 | dict.__delitem__(self, key) |
|
178 |
except KeyError |
|
|
178 | except KeyError as e: | |
|
179 | 179 | raise AttributeError(e) |
|
180 | 180 | |
|
181 | 181 |
@@ -151,7 +151,7 class AliasManager(Configurable): | |||
|
151 | 151 | """Define an alias, but don't raise on an AliasError.""" |
|
152 | 152 | try: |
|
153 | 153 | self.define_alias(name, cmd) |
|
154 |
except AliasError |
|
|
154 | except AliasError as e: | |
|
155 | 155 | error("Invalid alias: %s" % e) |
|
156 | 156 | |
|
157 | 157 | def define_alias(self, name, cmd): |
@@ -2454,7 +2454,7 class InteractiveShell(SingletonConfigurable): | |||
|
2454 | 2454 | with prepended_to_syspath(dname): |
|
2455 | 2455 | try: |
|
2456 | 2456 | py3compat.execfile(fname,*where) |
|
2457 |
except SystemExit |
|
|
2457 | except SystemExit as status: | |
|
2458 | 2458 | # If the call was made with 0 or None exit status (sys.exit(0) |
|
2459 | 2459 | # or sys.exit() ), don't bother showing a traceback, as both of |
|
2460 | 2460 | # these are considered normal by the OS: |
@@ -584,7 +584,7 class Magics(object): | |||
|
584 | 584 | # Do regular option processing |
|
585 | 585 | try: |
|
586 | 586 | opts,args = getopt(argv, opt_str, long_opts) |
|
587 |
except GetoptError |
|
|
587 | except GetoptError as e: | |
|
588 | 588 | raise UsageError('%s ( allowed: "%s" %s)' % (e.msg,opt_str, |
|
589 | 589 | " ".join(long_opts))) |
|
590 | 590 | for o,a in opts: |
@@ -513,7 +513,7 class CodeMagics(Magics): | |||
|
513 | 513 | if is_temp: |
|
514 | 514 | try: |
|
515 | 515 | return open(filename).read() |
|
516 |
except IOError |
|
|
516 | except IOError as msg: | |
|
517 | 517 | if msg.filename == filename: |
|
518 | 518 | warn('File not found. Did you forget to save?') |
|
519 | 519 | return |
@@ -113,7 +113,7 class NamespaceMagics(Magics): | |||
|
113 | 113 | if out == 'not found': |
|
114 | 114 | try: |
|
115 | 115 | filename = get_py_filename(parameter_s) |
|
116 |
except IOError |
|
|
116 | except IOError as msg: | |
|
117 | 117 | print msg |
|
118 | 118 | return |
|
119 | 119 | page.page(self.shell.inspector.format(open(filename).read())) |
@@ -221,7 +221,7 def page(strng, start=0, screen_lines=0, pager_cmd=None): | |||
|
221 | 221 | pager.write(strng) |
|
222 | 222 | pager.close() |
|
223 | 223 | retval = pager.close() # success returns None |
|
224 |
except IOError |
|
|
224 | except IOError as msg: # broken pipe when user quits | |
|
225 | 225 | if msg.args == (32,'Broken pipe'): |
|
226 | 226 | retval = None |
|
227 | 227 | else: |
@@ -201,7 +201,7 class TestMagicRunSimple(tt.TempFileMixin): | |||
|
201 | 201 | "for i in range(5):\n" |
|
202 | 202 | " try:\n" |
|
203 | 203 | " ip.magic('run %s')\n" |
|
204 |
" except NameError |
|
|
204 | " except NameError as e:\n" | |
|
205 | 205 | " print i;break\n" % empty.fname) |
|
206 | 206 | self.mktmp(py3compat.doctest_refactor_print(src)) |
|
207 | 207 | _ip.magic('run %s' % self.fname) |
@@ -875,7 +875,7 class VerboseTB(TBTools): | |||
|
875 | 875 | except (IndexError, UnicodeDecodeError): |
|
876 | 876 | # signals exit of tokenizer |
|
877 | 877 | pass |
|
878 |
except tokenize.TokenError |
|
|
878 | except tokenize.TokenError as msg: | |
|
879 | 879 | _m = ("An unexpected error occurred while tokenizing input\n" |
|
880 | 880 | "The following traceback may be corrupted or invalid\n" |
|
881 | 881 | "The error message is: %s\n" % msg) |
@@ -217,7 +217,7 class _BrowserLevel(object): | |||
|
217 | 217 | break |
|
218 | 218 | except (KeyboardInterrupt, SystemExit): |
|
219 | 219 | raise |
|
220 |
except Exception |
|
|
220 | except Exception as exc: | |
|
221 | 221 | have += 1 |
|
222 | 222 | self.items.append(_BrowserCachedItem(exc)) |
|
223 | 223 | self.exhausted = True |
@@ -260,7 +260,7 class _BrowserLevel(object): | |||
|
260 | 260 | value = attr.value(item) |
|
261 | 261 | except (KeyboardInterrupt, SystemExit): |
|
262 | 262 | raise |
|
263 |
except Exception |
|
|
263 | except Exception as exc: | |
|
264 | 264 | value = exc |
|
265 | 265 | # only store attribute if it exists (or we got an exception) |
|
266 | 266 | if value is not ipipe.noitem: |
@@ -652,7 +652,7 class _CommandFind(_CommandInput): | |||
|
652 | 652 | break # found something |
|
653 | 653 | except (KeyboardInterrupt, SystemExit): |
|
654 | 654 | raise |
|
655 |
except Exception |
|
|
655 | except Exception as exc: | |
|
656 | 656 | browser.report(exc) |
|
657 | 657 | curses.beep() |
|
658 | 658 | break # break on error |
@@ -677,7 +677,7 class _CommandFindBackwards(_CommandInput): | |||
|
677 | 677 | break # found something |
|
678 | 678 | except (KeyboardInterrupt, SystemExit): |
|
679 | 679 | raise |
|
680 |
except Exception |
|
|
680 | except Exception as exc: | |
|
681 | 681 | browser.report(exc) |
|
682 | 682 | curses.beep() |
|
683 | 683 | break # break on error |
@@ -946,7 +946,7 class ibrowse(ipipe.Display): | |||
|
946 | 946 | ) |
|
947 | 947 | except (KeyboardInterrupt, SystemExit): |
|
948 | 948 | raise |
|
949 |
except Exception |
|
|
949 | except Exception as exc: | |
|
950 | 950 | if not self.levels: |
|
951 | 951 | raise |
|
952 | 952 | self._calcheaderlines(oldlevels) |
@@ -1311,7 +1311,7 class ibrowse(ipipe.Display): | |||
|
1311 | 1311 | item = attr.value(item) |
|
1312 | 1312 | except (KeyboardInterrupt, SystemExit): |
|
1313 | 1313 | raise |
|
1314 |
except Exception |
|
|
1314 | except Exception as exc: | |
|
1315 | 1315 | self.report(exc) |
|
1316 | 1316 | else: |
|
1317 | 1317 | self.report("entering detail view for attribute %s..." % attr.name()) |
@@ -1638,7 +1638,7 class ibrowse(ipipe.Display): | |||
|
1638 | 1638 | value = attr.value(item) |
|
1639 | 1639 | except (SystemExit, KeyboardInterrupt): |
|
1640 | 1640 | raise |
|
1641 |
except Exception |
|
|
1641 | except Exception as exc: | |
|
1642 | 1642 | value = exc |
|
1643 | 1643 | if value is not ipipe.noitem: |
|
1644 | 1644 | attrstyle = ipipe.xrepr(value, "footer") |
@@ -154,7 +154,7 class IGridRenderer(wx.grid.PyGridCellRenderer): | |||
|
154 | 154 | try: |
|
155 | 155 | value = self.table._displayattrs[col].value(self.table.items[row]) |
|
156 | 156 | (align, width, text) = ipipe.xformat(value, "cell", self.maxchars) |
|
157 |
except Exception |
|
|
157 | except Exception as exc: | |
|
158 | 158 | (align, width, text) = ipipe.xformat(exc, "cell", self.maxchars) |
|
159 | 159 | return (align, text) |
|
160 | 160 | |
@@ -292,7 +292,7 class IGridTable(wx.grid.PyGridTableBase): | |||
|
292 | 292 | break |
|
293 | 293 | except (KeyboardInterrupt, SystemExit): |
|
294 | 294 | raise |
|
295 |
except Exception |
|
|
295 | except Exception as exc: | |
|
296 | 296 | have += 1 |
|
297 | 297 | self._append(exc) |
|
298 | 298 | self.iterator = None |
@@ -413,7 +413,7 class IGridGrid(wx.grid.Grid): | |||
|
413 | 413 | return None |
|
414 | 414 | try: |
|
415 | 415 | self.table.items = ipipe.deque(sorted(self.table.items, key=realkey, reverse=reverse)) |
|
416 |
except TypeError |
|
|
416 | except TypeError as exc: | |
|
417 | 417 | self.error_output("Exception encountered: %s" % exc) |
|
418 | 418 | return |
|
419 | 419 | # Find out where the object under the cursor went |
@@ -478,7 +478,7 class IGridGrid(wx.grid.Grid): | |||
|
478 | 478 | (align, width, text) = ipipe.xformat(value, "cell", self.maxchars) |
|
479 | 479 | except IndexError: |
|
480 | 480 | raise IndexError |
|
481 |
except Exception |
|
|
481 | except Exception as exc: | |
|
482 | 482 | (align, width, text) = ipipe.xformat(exc, "cell", self.maxchars) |
|
483 | 483 | return text |
|
484 | 484 | |
@@ -505,7 +505,7 class IGridGrid(wx.grid.Grid): | |||
|
505 | 505 | break |
|
506 | 506 | except (KeyboardInterrupt, SystemExit): |
|
507 | 507 | raise |
|
508 |
except Exception |
|
|
508 | except Exception as exc: | |
|
509 | 509 | frame.SetStatusText(str(exc)) |
|
510 | 510 | wx.Bell() |
|
511 | 511 | break # break on error |
@@ -529,7 +529,7 class IGridGrid(wx.grid.Grid): | |||
|
529 | 529 | break |
|
530 | 530 | except (KeyboardInterrupt, SystemExit): |
|
531 | 531 | raise |
|
532 |
except Exception |
|
|
532 | except Exception as exc: | |
|
533 | 533 | frame.SetStatusText(str(exc)) |
|
534 | 534 | wx.Bell() |
|
535 | 535 | break # break on error |
@@ -739,7 +739,7 class IGridGrid(wx.grid.Grid): | |||
|
739 | 739 | for i in xrange(count-1, current, -1): # some tabs don't close if we don't close in *reverse* order |
|
740 | 740 | nb.DeletePage(i) |
|
741 | 741 | frame._add_notebook(value) |
|
742 |
except TypeError |
|
|
742 | except TypeError as exc: | |
|
743 | 743 | if exc.__class__.__module__ == "exceptions": |
|
744 | 744 | msg = "%s: %s" % (exc.__class__.__name__, exc) |
|
745 | 745 | else: |
@@ -750,7 +750,7 class IGridGrid(wx.grid.Grid): | |||
|
750 | 750 | try: |
|
751 | 751 | attr = self.table._displayattrs[col] |
|
752 | 752 | value = attr.value(self.table.items[row]) |
|
753 |
except Exception |
|
|
753 | except Exception as exc: | |
|
754 | 754 | self.error_output(str(exc)) |
|
755 | 755 | else: |
|
756 | 756 | self._doenter(value) |
@@ -762,7 +762,7 class IGridGrid(wx.grid.Grid): | |||
|
762 | 762 | def enter(self, row): |
|
763 | 763 | try: |
|
764 | 764 | value = self.table.items[row] |
|
765 |
except Exception |
|
|
765 | except Exception as exc: | |
|
766 | 766 | self.error_output(str(exc)) |
|
767 | 767 | else: |
|
768 | 768 | self._doenter(value) |
@@ -774,7 +774,7 class IGridGrid(wx.grid.Grid): | |||
|
774 | 774 | try: |
|
775 | 775 | attr = self.table._displayattrs[col] |
|
776 | 776 | item = self.table.items[row] |
|
777 |
except Exception |
|
|
777 | except Exception as exc: | |
|
778 | 778 | self.error_output(str(exc)) |
|
779 | 779 | else: |
|
780 | 780 | attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")] |
@@ -784,7 +784,7 class IGridGrid(wx.grid.Grid): | |||
|
784 | 784 | try: |
|
785 | 785 | attr = self.table._displayattrs[col] |
|
786 | 786 | item = attr.value(self.table.items[row]) |
|
787 |
except Exception |
|
|
787 | except Exception as exc: | |
|
788 | 788 | self.error_output(str(exc)) |
|
789 | 789 | else: |
|
790 | 790 | attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")] |
@@ -819,7 +819,7 class IGridGrid(wx.grid.Grid): | |||
|
819 | 819 | """ |
|
820 | 820 | try: |
|
821 | 821 | value = self.table.items[row] |
|
822 |
except Exception |
|
|
822 | except Exception as exc: | |
|
823 | 823 | self.error_output(str(exc)) |
|
824 | 824 | else: |
|
825 | 825 | self.quit(value) |
@@ -827,7 +827,7 class IGridGrid(wx.grid.Grid): | |||
|
827 | 827 | def pickinput(self, row): |
|
828 | 828 | try: |
|
829 | 829 | value = self.table.items[row] |
|
830 |
except Exception |
|
|
830 | except Exception as exc: | |
|
831 | 831 | self.error_output(str(exc)) |
|
832 | 832 | else: |
|
833 | 833 | api = ipapi.get() |
@@ -838,7 +838,7 class IGridGrid(wx.grid.Grid): | |||
|
838 | 838 | try: |
|
839 | 839 | attr = self.table._displayattrs[col] |
|
840 | 840 | value = attr.value(self.table.items[row]) |
|
841 |
except Exception |
|
|
841 | except Exception as exc: | |
|
842 | 842 | self.error_output(str(exc)) |
|
843 | 843 | else: |
|
844 | 844 | api = ipapi.get() |
@@ -851,7 +851,7 class IGridGrid(wx.grid.Grid): | |||
|
851 | 851 | """ |
|
852 | 852 | try: |
|
853 | 853 | value = [self.table.items[row] for row in rows] |
|
854 |
except Exception |
|
|
854 | except Exception as exc: | |
|
855 | 855 | self.error_output(str(exc)) |
|
856 | 856 | else: |
|
857 | 857 | self.quit(value) |
@@ -870,7 +870,7 class IGridGrid(wx.grid.Grid): | |||
|
870 | 870 | raise |
|
871 | 871 | except Exception: |
|
872 | 872 | raise #pass |
|
873 |
except Exception |
|
|
873 | except Exception as exc: | |
|
874 | 874 | self.error_output(str(exc)) |
|
875 | 875 | else: |
|
876 | 876 | self.quit(values) |
@@ -879,7 +879,7 class IGridGrid(wx.grid.Grid): | |||
|
879 | 879 | try: |
|
880 | 880 | attr = self.table._displayattrs[col] |
|
881 | 881 | value = attr.value(self.table.items[row]) |
|
882 |
except Exception |
|
|
882 | except Exception as exc: | |
|
883 | 883 | self.error_output(str(exc)) |
|
884 | 884 | else: |
|
885 | 885 | self.quit(value) |
@@ -959,7 +959,7 class IGridFrame(wx.Frame): | |||
|
959 | 959 | if dlg.ShowModal() == wx.ID_OK: |
|
960 | 960 | try: |
|
961 | 961 | milliseconds = int(dlg.GetValue()) |
|
962 |
except ValueError |
|
|
962 | except ValueError as exc: | |
|
963 | 963 | self.SetStatusText(str(exc)) |
|
964 | 964 | else: |
|
965 | 965 | table.timer.Start(milliseconds=milliseconds, oneShot=False) |
@@ -1796,7 +1796,7 class ifilter(Pipe): | |||
|
1796 | 1796 | ok += 1 |
|
1797 | 1797 | except (KeyboardInterrupt, SystemExit): |
|
1798 | 1798 | raise |
|
1799 |
except Exception |
|
|
1799 | except Exception as exc: | |
|
1800 | 1800 | if self.errors == "drop": |
|
1801 | 1801 | pass # Ignore errors |
|
1802 | 1802 | elif self.errors == "keep": |
@@ -1869,7 +1869,7 class ieval(Pipe): | |||
|
1869 | 1869 | yield do(item) |
|
1870 | 1870 | except (KeyboardInterrupt, SystemExit): |
|
1871 | 1871 | raise |
|
1872 |
except Exception |
|
|
1872 | except Exception as exc: | |
|
1873 | 1873 | if self.errors == "drop": |
|
1874 | 1874 | pass # Ignore errors |
|
1875 | 1875 | elif self.errors == "keep": |
@@ -2040,7 +2040,7 class iless(Display): | |||
|
2040 | 2040 | pager.write("\n") |
|
2041 | 2041 | finally: |
|
2042 | 2042 | pager.close() |
|
2043 |
except Exception |
|
|
2043 | except Exception as exc: | |
|
2044 | 2044 | print "%s: %s" % (exc.__class__.__name__, str(exc)) |
|
2045 | 2045 | |
|
2046 | 2046 | |
@@ -2187,7 +2187,7 class idump(Display): | |||
|
2187 | 2187 | value = attr.value(item) |
|
2188 | 2188 | except (KeyboardInterrupt, SystemExit): |
|
2189 | 2189 | raise |
|
2190 |
except Exception |
|
|
2190 | except Exception as exc: | |
|
2191 | 2191 | value = exc |
|
2192 | 2192 | (align, width, text) = xformat(value, "cell", self.maxattrlength) |
|
2193 | 2193 | colwidths[attr] = max(colwidths[attr], width) |
@@ -246,7 +246,7 class FrontEndBase(object): | |||
|
246 | 246 | |
|
247 | 247 | try: |
|
248 | 248 | result = self.shell.execute(block) |
|
249 |
except Exception |
|
|
249 | except Exception as e: | |
|
250 | 250 | e = self._add_block_id_for_failure(e, blockID=blockID) |
|
251 | 251 | e = self.update_cell_prompt(e, blockID=blockID) |
|
252 | 252 | e = self.render_error(e) |
@@ -161,7 +161,7 class LineFrontEndBase(FrontEndBase): | |||
|
161 | 161 | is_complete = codeop.compile_command(clean_string, |
|
162 | 162 | "<string>", "exec") |
|
163 | 163 | self.release_output() |
|
164 |
except Exception |
|
|
164 | except Exception as e: | |
|
165 | 165 | # XXX: Hack: return True so that the |
|
166 | 166 | # code gets executed and the error captured. |
|
167 | 167 | is_complete = True |
@@ -5,7 +5,7 ipython. | |||
|
5 | 5 | |
|
6 | 6 | try: |
|
7 | 7 | import wx |
|
8 |
except ImportError |
|
|
8 | except ImportError as e: | |
|
9 | 9 | e.args[0] = """%s |
|
10 | 10 | ________________________________________________________________________________ |
|
11 | 11 | You need wxPython to run this application. |
@@ -8,7 +8,7 try: | |||
|
8 | 8 | import numpy.testing as npt |
|
9 | 9 | |
|
10 | 10 | from IPython.extensions import octavemagic |
|
11 |
except Exception |
|
|
11 | except Exception as e: | |
|
12 | 12 | __test__ = False |
|
13 | 13 | |
|
14 | 14 | global octave |
@@ -79,7 +79,7 try: | |||
|
79 | 79 | import errno |
|
80 | 80 | import traceback |
|
81 | 81 | import signal |
|
82 |
except ImportError |
|
|
82 | except ImportError as e: | |
|
83 | 83 | raise ImportError (str(e) + """ |
|
84 | 84 | |
|
85 | 85 | A critical module was not found. Probably this operating system does not |
@@ -265,10 +265,10 def run (command, timeout=-1, withexitstatus=False, events=None, extra_args=None | |||
|
265 | 265 | else: |
|
266 | 266 | raise TypeError ('The callback must be a string or function type.') |
|
267 | 267 | event_count = event_count + 1 |
|
268 |
except TIMEOUT |
|
|
268 | except TIMEOUT as e: | |
|
269 | 269 | child_result_list.append(child.before) |
|
270 | 270 | break |
|
271 |
except EOF |
|
|
271 | except EOF as e: | |
|
272 | 272 | child_result_list.append(child.before) |
|
273 | 273 | break |
|
274 | 274 | child_result = child._empty_buffer.join(child_result_list) |
@@ -552,7 +552,7 class spawnb(object): | |||
|
552 | 552 | if self.use_native_pty_fork: |
|
553 | 553 | try: |
|
554 | 554 | self.pid, self.child_fd = pty.fork() |
|
555 |
except OSError |
|
|
555 | except OSError as e: | |
|
556 | 556 | raise ExceptionPexpect('Error! pty.fork() failed: ' + str(e)) |
|
557 | 557 | else: # Use internal __fork_pty |
|
558 | 558 | self.pid, self.child_fd = self.__fork_pty() |
@@ -857,7 +857,7 class spawnb(object): | |||
|
857 | 857 | if self.child_fd in r: |
|
858 | 858 | try: |
|
859 | 859 | s = os.read(self.child_fd, size) |
|
860 |
except OSError |
|
|
860 | except OSError as e: # Linux does this | |
|
861 | 861 | self.flag_eof = True |
|
862 | 862 | raise EOF ('End Of File (EOF) in read_nonblocking(). Exception style platform.') |
|
863 | 863 | if s == b'': # BSD style |
@@ -1106,7 +1106,7 class spawnb(object): | |||
|
1106 | 1106 | else: |
|
1107 | 1107 | return False |
|
1108 | 1108 | return False |
|
1109 |
except OSError |
|
|
1109 | except OSError as e: | |
|
1110 | 1110 | # I think there are kernel timing issues that sometimes cause |
|
1111 | 1111 | # this to happen. I think isalive() reports True, but the |
|
1112 | 1112 | # process is dead to the kernel. |
@@ -1177,7 +1177,7 class spawnb(object): | |||
|
1177 | 1177 | if pid == 0: |
|
1178 | 1178 | try: |
|
1179 | 1179 | pid, status = os.waitpid(self.pid, waitpid_options) ### os.WNOHANG) # Solaris! |
|
1180 |
except OSError |
|
|
1180 | except OSError as e: # This should never happen... | |
|
1181 | 1181 | if e[0] == errno.ECHILD: |
|
1182 | 1182 | raise ExceptionPexpect ('isalive() encountered condition that should never happen. There was no child process. Did someone else call waitpid() on our process?') |
|
1183 | 1183 | else: |
@@ -1424,7 +1424,7 class spawnb(object): | |||
|
1424 | 1424 | incoming = incoming + c |
|
1425 | 1425 | if timeout is not None: |
|
1426 | 1426 | timeout = end_time - time.time() |
|
1427 |
except EOF |
|
|
1427 | except EOF as e: | |
|
1428 | 1428 | self.buffer = self._empty_buffer |
|
1429 | 1429 | self.before = incoming |
|
1430 | 1430 | self.after = EOF |
@@ -1437,7 +1437,7 class spawnb(object): | |||
|
1437 | 1437 | self.match = None |
|
1438 | 1438 | self.match_index = None |
|
1439 | 1439 | raise EOF (str(e) + '\n' + str(self)) |
|
1440 |
except TIMEOUT |
|
|
1440 | except TIMEOUT as e: | |
|
1441 | 1441 | self.buffer = incoming |
|
1442 | 1442 | self.before = incoming |
|
1443 | 1443 | self.after = TIMEOUT |
@@ -45,7 +45,7 class Handler (SocketServer.BaseRequestHandler): | |||
|
45 | 45 | chan = self.ssh_transport.open_channel('direct-tcpip', |
|
46 | 46 | (self.chain_host, self.chain_port), |
|
47 | 47 | self.request.getpeername()) |
|
48 |
except Exception |
|
|
48 | except Exception as e: | |
|
49 | 49 | logger.debug('Incoming request to %s:%d failed: %s' % (self.chain_host, |
|
50 | 50 | self.chain_port, |
|
51 | 51 | repr(e))) |
@@ -447,7 +447,7 class NotebookApp(BaseIPythonApplication): | |||
|
447 | 447 | for port in random_ports(self.port, self.port_retries+1): |
|
448 | 448 | try: |
|
449 | 449 | self.http_server.listen(port, self.ip) |
|
450 |
except socket.error |
|
|
450 | except socket.error as e: | |
|
451 | 451 | if e.errno != errno.EADDRINUSE: |
|
452 | 452 | raise |
|
453 | 453 | self.log.info('The port %i is already in use, trying another random port.' % port) |
@@ -111,7 +111,7 class HtmlExporter(object): | |||
|
111 | 111 | # Perform the export! |
|
112 | 112 | try: |
|
113 | 113 | return exporter(html, self.filename, self.image_tag) |
|
114 |
except Exception |
|
|
114 | except Exception as e: | |
|
115 | 115 | msg = "Error exporting HTML to %s\n" % self.filename + str(e) |
|
116 | 116 | reply = QtGui.QMessageBox.warning(parent, 'Error', msg, |
|
117 | 117 | QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) |
@@ -551,7 +551,7 def _dict_pprinter_factory(start, end, basetype=None): | |||
|
551 | 551 | keys = obj.keys() |
|
552 | 552 | try: |
|
553 | 553 | keys.sort() |
|
554 |
except Exception |
|
|
554 | except Exception as e: | |
|
555 | 555 | # Sometimes the keys don't sort. |
|
556 | 556 | pass |
|
557 | 557 | for idx, key in enumerate(keys): |
@@ -151,7 +151,7 class AsyncResult(object): | |||
|
151 | 151 | else: |
|
152 | 152 | results = error.collect_exceptions(results, self._fname) |
|
153 | 153 | self._result = self._reconstruct_result(results) |
|
154 |
except Exception |
|
|
154 | except Exception as e: | |
|
155 | 155 | self._exception = e |
|
156 | 156 | self._success = False |
|
157 | 157 | else: |
@@ -675,7 +675,7 class AsyncHubResult(AsyncResult): | |||
|
675 | 675 | else: |
|
676 | 676 | results = error.collect_exceptions(results, self._fname) |
|
677 | 677 | self._result = self._reconstruct_result(results) |
|
678 |
except Exception |
|
|
678 | except Exception as e: | |
|
679 | 679 | self._exception = e |
|
680 | 680 | self._success = False |
|
681 | 681 | else: |
@@ -683,4 +683,4 class AsyncHubResult(AsyncResult): | |||
|
683 | 683 | finally: |
|
684 | 684 | self._metadata = map(self._client.metadata.get, self.msg_ids) |
|
685 | 685 | |
|
686 | __all__ = ['AsyncResult', 'AsyncMapResult', 'AsyncHubResult'] No newline at end of file | |
|
686 | __all__ = ['AsyncResult', 'AsyncMapResult', 'AsyncHubResult'] |
@@ -107,7 +107,7 def teardown(): | |||
|
107 | 107 | if p.poll() is None: |
|
108 | 108 | try: |
|
109 | 109 | p.stop() |
|
110 |
except Exception |
|
|
110 | except Exception as e: | |
|
111 | 111 | print e |
|
112 | 112 | pass |
|
113 | 113 | if p.poll() is None: |
@@ -78,7 +78,7 def line_edit_f(self, cmd ): | |||
|
78 | 78 | for l in curdata: |
|
79 | 79 | try: |
|
80 | 80 | l2 = eval(cmd) |
|
81 |
except Exception |
|
|
81 | except Exception as e: | |
|
82 | 82 | print "Dropping exception",e,"on line:",l |
|
83 | 83 | continue |
|
84 | 84 | newlines.append(l2) |
@@ -95,4 +95,4 def line_edit_complete_f(self,event): | |||
|
95 | 95 | |
|
96 | 96 | ip.set_hook('complete_command', line_edit_complete_f , str_key = '%led') |
|
97 | 97 | |
|
98 | ip.define_magic('led', line_edit_f) No newline at end of file | |
|
98 | ip.define_magic('led', line_edit_f) |
@@ -308,7 +308,7 class DocTestCase(doctests.DocTestCase): | |||
|
308 | 308 | # and letting any other error propagate. |
|
309 | 309 | try: |
|
310 | 310 | super(DocTestCase, self).tearDown() |
|
311 |
except AttributeError |
|
|
311 | except AttributeError as exc: | |
|
312 | 312 | if exc.args[0] != self._result_var: |
|
313 | 313 | raise |
|
314 | 314 |
@@ -282,7 +282,7 If no filename is given, or if filename is -, read standard input.""" | |||
|
282 | 282 | else: |
|
283 | 283 | try: |
|
284 | 284 | stream = open(fname) |
|
285 |
except IOError |
|
|
285 | except IOError as msg: | |
|
286 | 286 | print >> sys.stderr, msg |
|
287 | 287 | sys.exit(1) |
|
288 | 288 | |
@@ -294,7 +294,7 If no filename is given, or if filename is -, read standard input.""" | |||
|
294 | 294 | try: |
|
295 | 295 | # write colorized version to stdout |
|
296 | 296 | parser.format(stream.read(),scheme=opts.scheme_name) |
|
297 |
except IOError |
|
|
297 | except IOError as msg: | |
|
298 | 298 | # if user reads through a pager and quits, don't print traceback |
|
299 | 299 | if msg.args != (32,'Broken pipe'): |
|
300 | 300 | raise |
@@ -34,7 +34,7 def read_no_interrupt(p): | |||
|
34 | 34 | |
|
35 | 35 | try: |
|
36 | 36 | return p.read() |
|
37 |
except IOError |
|
|
37 | except IOError as err: | |
|
38 | 38 | if err.errno != errno.EINTR: |
|
39 | 39 | raise |
|
40 | 40 |
@@ -19,7 +19,7 def daemonize(): | |||
|
19 | 19 | for i in range(3): |
|
20 | 20 | try: |
|
21 | 21 | os.dup2(null, i) |
|
22 |
except OSError |
|
|
22 | except OSError as e: | |
|
23 | 23 | if e.errno != errno.EBADF: |
|
24 | 24 | raise |
|
25 | 25 | os.close(null) |
@@ -121,7 +121,7 class Struct(dict): | |||
|
121 | 121 | ) |
|
122 | 122 | try: |
|
123 | 123 | self.__setitem__(key, value) |
|
124 |
except KeyError |
|
|
124 | except KeyError as e: | |
|
125 | 125 | raise AttributeError(e) |
|
126 | 126 | |
|
127 | 127 | def __getattr__(self, key): |
@@ -85,7 +85,7 class PickleShareDB(collections.MutableMapping): | |||
|
85 | 85 | pickled = pickle.dump(value,fil.open('wb'), protocol=2) |
|
86 | 86 | try: |
|
87 | 87 | self.cache[fil] = (value,fil.mtime) |
|
88 |
except OSError |
|
|
88 | except OSError as e: | |
|
89 | 89 | if e.errno != 2: |
|
90 | 90 | raise |
|
91 | 91 |
@@ -897,7 +897,7 class KernelManager(HasTraits): | |||
|
897 | 897 | # Attempt to kill the kernel. |
|
898 | 898 | try: |
|
899 | 899 | self.kernel.kill() |
|
900 |
except OSError |
|
|
900 | except OSError as e: | |
|
901 | 901 | # In Windows, we will get an Access Denied error if the process |
|
902 | 902 | # has already terminated. Ignore it. |
|
903 | 903 | if sys.platform == 'win32': |
General Comments 0
You need to be logged in to leave comments.
Login now