From 848c0f5dfff84d7d76d719ded294a2854aab3722 2011-04-11 00:31:02 From: Thomas Kluyver Date: 2011-04-11 00:31:02 Subject: [PATCH] Suppress auto_rewrite of exit autocall. --- diff --git a/IPython/core/autocall.py b/IPython/core/autocall.py index d02e7ae..af3b532 100644 --- a/IPython/core/autocall.py +++ b/IPython/core/autocall.py @@ -36,6 +36,7 @@ class IPyAutocall(object): develop macro-like mechanisms. """ _ip = None + rewrite = True def __init__(self, ip=None): self._ip = ip @@ -51,6 +52,7 @@ class IPyAutocall(object): class ExitAutocall(IPyAutocall): """An autocallable object which will be added to the user namespace so that exit, exit(), quit or quit() are all valid ways to close the shell.""" + rewrite = False def __call__(self): self._ip.ask_exit() diff --git a/IPython/core/prefilter.py b/IPython/core/prefilter.py index 7bae693..d138bea 100755 --- a/IPython/core/prefilter.py +++ b/IPython/core/prefilter.py @@ -894,7 +894,7 @@ class AutoHandler(PrefilterHandler): return line force_auto = isinstance(obj, IPyAutocall) - auto_rewrite = True + auto_rewrite = getattr(obj, 'rewrite', True) if pre == ESC_QUOTE: # Auto-quote splitting on whitespace