Skip to content

Conversation

@minrk
Copy link
Member

@minrk minrk commented May 4, 2011

Since user code can be executed in the prefilter step (e.g. via Aliases), catch and print those errors like normal code.

I could also be less aggressive and only catch AliasErrors.

Closes #216

@rkern
Copy link
Contributor

rkern commented May 4, 2011

Why except SystemExit: instead of except Exception:?

@minrk
Copy link
Member Author

minrk commented May 4, 2011

Because I managed to commit while I was checking that the test I added failed when the exception wasn't caught.

Fixed now.

@takluyver
Copy link
Member

Looks good to me. I'll test it later.

@takluyver
Copy link
Member

That's working here. Is it worth catching the specific case (wrong number of arguments for an alias) and displaying a short error message, rather than the full traceback?

@minrk
Copy link
Member Author

minrk commented May 5, 2011

If we want IPython to die at every other error, I can only catch the AliasError. I don't actually think that's a good idea, but it would conform with current practices of making IPython crash and exit at the first sign of unrecognized trouble.

I think IPython should only crash when something is unrecoverable, not at every possible bug in IPython, but that's something of a separate issue.

@rkern
Copy link
Contributor

rkern commented May 5, 2011

I think he's suggesting that you catch the AliasError specifically to make a more focused error message, then catch the rest of the exceptions with the general except Exception:

@takluyver
Copy link
Member

As Robert says - I'm not suggesting you remove the general except handler. Just that, in addition, I'd prefer to avoid a traceback of IPython internals for a simple mistake in user code. E.g. for magic functions, if the user's command is wrong in some way, we often just print a single line explanation of the problem, and return from the function.

instead of full traceback

use prefilter_failed flag to prevent duplicate code
@minrk
Copy link
Member Author

minrk commented May 5, 2011

Okay, now the message is just the short 'ERROR: ' on AliasErrors, but all exceptions are caught.

@takluyver
Copy link
Member

OK, looks good to me.

minrk added a commit that referenced this pull request May 9, 2011
Prevent prefilter from crashing IPython

closes gh-216
@minrk minrk merged commit 285a7f7 into ipython:master May 9, 2011
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Prevent prefilter from crashing IPython

closes ipythongh-216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crash of ipython when alias is used with %s and echo

3 participants