Rewrite quit()/exit()/Quit()/Exit() calls as magic #353
dwf wants to merge 2 commits into ipython:master from dwf:rewrite_quit_exit_parens
Commits on Apr 10, 2011
Apr 10, 2011
After some discussion with Fernando it was decided that detecting calls on all magics as in pull request #352 was probably overkill. Opted for detecting with a regex possible calls to absent Quitter objects and rewriting them (as before), with visual notification of this rewrite. This is done with a QuitterChecker which has priority just below that of AutoMagicChecker. The only case where you will get a NameError now is if you input newlines before the starting and closing paren, but that's sufficiently crazy as to not be worth considering (it takes one, optional, integer argument in the real Python shell, why you'd ever need newlines...). Also subclassed MagicHandler to avoid doing the regex check twice (once in the Checker and once in the Handler) and factored out the creation of the replacement command so as to avoid potential code rot.