Show More
@@ -35,22 +35,9 b' class TryNext(IPythonCoreError):' | |||
|
35 | 35 | """Try next hook exception. |
|
36 | 36 | |
|
37 | 37 | Raise this in your hook function to indicate that the next hook handler |
|
38 |
should be used to handle the operation. |
|
|
39 | constructor those arguments will be used by the next hook instead of the | |
|
40 | original ones. | |
|
41 | ||
|
42 | A _msg argument will not be passed on, so it can be used as a displayable | |
|
43 | error message. | |
|
38 | should be used to handle the operation. | |
|
44 | 39 | """ |
|
45 | 40 | |
|
46 | def __init__(self, _msg="", *args, **kwargs): | |
|
47 | self.args = args | |
|
48 | self.kwargs = kwargs | |
|
49 | self.msg = _msg | |
|
50 | ||
|
51 | def __str__(self): | |
|
52 | return str(self.msg) | |
|
53 | ||
|
54 | 41 | class UsageError(IPythonCoreError): |
|
55 | 42 | """Error in magic function arguments, etc. |
|
56 | 43 |
@@ -131,17 +131,15 b' class CommandChainDispatcher:' | |||
|
131 | 131 | This will call all funcs in chain with the same args as were given to |
|
132 | 132 | this function, and return the result of first func that didn't raise |
|
133 | 133 | TryNext""" |
|
134 | ||
|
134 | last_exc = TryNext() | |
|
135 | 135 | for prio,cmd in self.chain: |
|
136 | 136 | #print "prio",prio,"cmd",cmd #dbg |
|
137 | 137 | try: |
|
138 | 138 | return cmd(*args, **kw) |
|
139 |
except TryNext |
|
|
140 | if exc.args or exc.kwargs: | |
|
141 | args = exc.args | |
|
142 | kw = exc.kwargs | |
|
139 | except TryNext as exc: | |
|
140 | last_exc = exc | |
|
143 | 141 | # if no function will accept it, raise TryNext up to the caller |
|
144 | raise TryNext(*args, **kw) | |
|
142 | raise last_exc | |
|
145 | 143 | |
|
146 | 144 | def __str__(self): |
|
147 | 145 | return str(self.chain) |
@@ -15,9 +15,8 b' def win32_clipboard_get():' | |||
|
15 | 15 | try: |
|
16 | 16 | import win32clipboard |
|
17 | 17 | except ImportError: |
|
18 |
|
|
|
19 | "extensions: http://sourceforge.net/projects/pywin32/") | |
|
20 | raise TryNext(_msg=message) | |
|
18 | raise TryNext("Getting text from the clipboard requires the pywin32 " | |
|
19 | "extensions: http://sourceforge.net/projects/pywin32/") | |
|
21 | 20 | win32clipboard.OpenClipboard() |
|
22 | 21 | text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT) |
|
23 | 22 | # FIXME: convert \r\n to \n? |
@@ -44,9 +43,8 b' def tkinter_clipboard_get():' | |||
|
44 | 43 | try: |
|
45 | 44 | import Tkinter |
|
46 | 45 | except ImportError: |
|
47 |
|
|
|
48 | "requires Tkinter.") | |
|
49 | raise TryNext(_msg=message) | |
|
46 | raise TryNext("Getting text from the clipboard on this platform " | |
|
47 | "requires Tkinter.") | |
|
50 | 48 | root = Tkinter.Tk() |
|
51 | 49 | root.withdraw() |
|
52 | 50 | text = root.clipboard_get() |
@@ -25,3 +25,11 b' Other new features' | |||
|
25 | 25 | :meth:`~IPython.core.interactiveshell.InteractiveShell.run_cell` to |
|
26 | 26 | :meth:`~IPython.core.interactiveshell.InteractiveShell.run_ast_nodes` |
|
27 | 27 | is now configurable. |
|
28 | ||
|
29 | Backwards incompatible changes | |
|
30 | ------------------------------ | |
|
31 | ||
|
32 | * The exception :exc:`IPython.core.error.TryNext` previously accepted | |
|
33 | arguments and keyword arguments to be passed to the next implementation | |
|
34 | of the hook. This feature was removed as it made error message propagation | |
|
35 | difficult and violated the principle of loose coupling. |
General Comments 0
You need to be logged in to leave comments.
Login now