##// END OF EJS Templates
Remove args/kwargs handling in TryNext....
Bradley M. Froehle -
Show More
@@ -35,22 +35,9 b' class TryNext(IPythonCoreError):'
35 """Try next hook exception.
35 """Try next hook exception.
36
36
37 Raise this in your hook function to indicate that the next hook handler
37 Raise this in your hook function to indicate that the next hook handler
38 should be used to handle the operation. If you pass arguments to the
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.
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 class UsageError(IPythonCoreError):
41 class UsageError(IPythonCoreError):
55 """Error in magic function arguments, etc.
42 """Error in magic function arguments, etc.
56
43
@@ -131,17 +131,15 b' class CommandChainDispatcher:'
131 This will call all funcs in chain with the same args as were given to
131 This will call all funcs in chain with the same args as were given to
132 this function, and return the result of first func that didn't raise
132 this function, and return the result of first func that didn't raise
133 TryNext"""
133 TryNext"""
134
134 last_exc = TryNext()
135 for prio,cmd in self.chain:
135 for prio,cmd in self.chain:
136 #print "prio",prio,"cmd",cmd #dbg
136 #print "prio",prio,"cmd",cmd #dbg
137 try:
137 try:
138 return cmd(*args, **kw)
138 return cmd(*args, **kw)
139 except TryNext, exc:
139 except TryNext as exc:
140 if exc.args or exc.kwargs:
140 last_exc = exc
141 args = exc.args
142 kw = exc.kwargs
143 # if no function will accept it, raise TryNext up to the caller
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 def __str__(self):
144 def __str__(self):
147 return str(self.chain)
145 return str(self.chain)
@@ -15,9 +15,8 b' def win32_clipboard_get():'
15 try:
15 try:
16 import win32clipboard
16 import win32clipboard
17 except ImportError:
17 except ImportError:
18 message = ("Getting text from the clipboard requires the pywin32 "
18 raise TryNext("Getting text from the clipboard requires the pywin32 "
19 "extensions: http://sourceforge.net/projects/pywin32/")
19 "extensions: http://sourceforge.net/projects/pywin32/")
20 raise TryNext(_msg=message)
21 win32clipboard.OpenClipboard()
20 win32clipboard.OpenClipboard()
22 text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
21 text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
23 # FIXME: convert \r\n to \n?
22 # FIXME: convert \r\n to \n?
@@ -44,9 +43,8 b' def tkinter_clipboard_get():'
44 try:
43 try:
45 import Tkinter
44 import Tkinter
46 except ImportError:
45 except ImportError:
47 message = ("Getting text from the clipboard on this platform "
46 raise TryNext("Getting text from the clipboard on this platform "
48 "requires Tkinter.")
47 "requires Tkinter.")
49 raise TryNext(_msg=message)
50 root = Tkinter.Tk()
48 root = Tkinter.Tk()
51 root.withdraw()
49 root.withdraw()
52 text = root.clipboard_get()
50 text = root.clipboard_get()
@@ -25,3 +25,11 b' Other new features'
25 :meth:`~IPython.core.interactiveshell.InteractiveShell.run_cell` to
25 :meth:`~IPython.core.interactiveshell.InteractiveShell.run_cell` to
26 :meth:`~IPython.core.interactiveshell.InteractiveShell.run_ast_nodes`
26 :meth:`~IPython.core.interactiveshell.InteractiveShell.run_ast_nodes`
27 is now configurable.
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