Related to #337, people coming from generations-old IPython might still be tempted to type quit() and be miffed to find out it doesn't exist anymore. Ideally these two should probably 'just work', or the error should at least be something more sensible than a NameError.
In general trying to use automagic with call () parens should probably not NameError, but rather direct the user to %magic. I've been looking at InteractiveShell for a way to do this generally but I'm not sure there is a good one. Seems like catching a NameError in run_code is the way to go but we're already several levels down the call stack from being able to inspect the raw code to see if it is a magic gone wrong.
I'd start by looking at amending AutomagicChecker (in core/prefilter.py) to catch these cases. We should already be checking we're not colliding with the user namespace.
Had a look at that already, the trouble I see is a) there's no way that I can see to cleanly halt processing and tell the user they made a mistake from within a Checker (though it just occurred to me that you might be able to do it via a custom Handler class that messes with the shell object), b) the whole collisions issue: right now "guiref = lambda x: 5" means that subsequent calls to guiref(3) get handed off to that lambda function, and I think that's the correct behaviour. So I guess this handler would have to inspect the user namespace for things that shadow a magic command and defer to that, but is there a way for the handler to abort and let the checker pipeline continue?
Wait, checkers have a reference to the shell object too. So I guess a) is possible via a call to showtraceback(), and this is all accomplishable with some care in AutoMagicChecker.
I'm not sure that calling showtraceback in a checker is the right way to do it. That sounds messy. But you could try the shell.auto_rewrite_input method in the handler. So exit() gets rewritten to exit.
Well, you only want to rewrite it in the case that there is no variable 'exit' in the user namespace; so I guess the AutoMagicChecker would conditionally dispatch one handler or the other? (Or none). I agree auto_rewrite_input should be called in that case.
I think exit() and quit() should probably be rewritten, but it's unclear what to do about other magics, if anything. That's where showtraceback would come in; raise another exception explaining that you don't call magics with parens like that in general. But I guess the two issues can be dealt with in separate patches.
exit() and quit() now seem to work fine.