Skip to content

Rewrite quit()/exit()/Quit()/Exit() calls as magic #353

wants to merge 2 commits into from
Commits on Apr 10, 2011
  1. @dwf

    Add quitter checker and handler for quit(), etc. calls. Closes gh-142.

    dwf committed 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
    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.
  2. @dwf

    Tests for the quitter handler.

    dwf committed Apr 10, 2011
    Also amended the tester to run within the builtin trap context manager
    so that the builtins don't interfere.
Something went wrong with that request. Please try again.