-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Display message from TryNext error in magic_paste #1741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if exc.args or exc.kwargs: | ||
args = exc.args | ||
kw = exc.kwargs | ||
# if no function will accept it, raise TryNext up to the caller | ||
raise TryNext(*args, **kw) | ||
raise lastexc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behavior slightly, as before we'd guarantee the exception's args
and kw
attributes would be as passed to __call__
, but now we only take the results from the raised exception (which likely have args = ()
, and kw = {}
).
Is the ability of the exception to change the calling arguments ever actually used? I can't seem to find an instance of this in the IPython source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a quick look, here and in magic_paste are the only code where TryNext
is caught and captured. I think the ability to change args/kwargs is intended to act within CommandChainDispatcher
, not to propagate to calling code, and this doesn't affect that. But no, I don't think it's actually used at all. It's hard to see a use case that maintains weak coupling. Maybe it should just be ditched...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consider removing the args/kw capability in TryNext
. It's been present, in its current form, since the dawn of time (or at least since 2f09c2a which is the start of the history in git).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's take this to the mailing list. I'll make a post about it.
Certainly the PR works:
|
@takluyver, |
Started a branch for this: https://github.com/bfroehle/ipython/compare/_1736_try_next Haven't tested it, but can open a pull request later this evening. |
@bfroehle : At a glance, that branch looks good, so go for a pull request. I'm with my family for a long weekend, so I'm checking email, but I don't have much time to actually code. |
Superseded by #1850 - closing. |
If you do %paste on a system without Tkinter installed, this makes sure you get the more informative error message.
Closes gh-1736