diff --git a/IPython/core/history.py b/IPython/core/history.py index 7f2af33..ccf1873 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -20,7 +20,6 @@ import sys # Our own packages import IPython.utils.io -from IPython.core import ipapi from IPython.core.inputlist import InputList from IPython.utils.pickleshare import PickleShareDB from IPython.utils.io import ask_yes_no @@ -118,7 +117,7 @@ class HistoryManager(object): print(r"only has ASCII characters, e.g. c:\home") print("Now it is", self.ipython_dir) sys.exit() - self.shadow_hist = ShadowHist(self.shadow_db) + self.shadow_hist = ShadowHist(self.shadow_db, self.shell) def save_hist(self): """Save input history to a file (via readline library).""" @@ -456,11 +455,12 @@ def rep_f(self, arg): _sentinel = object() class ShadowHist(object): - def __init__(self, db): + def __init__(self, db, shell): # cmd => idx mapping self.curidx = 0 self.db = db self.disabled = False + self.shell = shell def inc_idx(self): idx = self.db.get('shadowhist_idx', 1) @@ -478,7 +478,7 @@ class ShadowHist(object): #print("new", newidx) # dbg self.db.hset('shadowhist',ent, newidx) except: - ipapi.get().showtraceback() + self.shell.showtraceback() print("WARNING: disabling shadow history") self.disabled = True diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index efe053f..614e252 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -154,6 +154,8 @@ class InteractiveShell(Configurable, Magic): deep_reload = CBool(False, config=True) displayhook_class = Type(DisplayHook) exit_now = CBool(False) + # Monotonically increasing execution counter + execution_count = Int(1) filename = Str("") ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__ @@ -370,6 +372,10 @@ class InteractiveShell(Configurable, Magic): self.compile = codeop.CommandCompiler() # User input buffers + # NOTE: these variables are slated for full removal, once we are 100% + # sure that the new execution logic is solid. We will delte runlines, + # push_line and these buffers, as all input will be managed by the + # frontends via an inputsplitter instance. self.buffer = [] self.buffer_raw = [] @@ -399,9 +405,6 @@ class InteractiveShell(Configurable, Magic): # Indentation management self.indent_current_nsp = 0 - # Increasing execution counter - self.execution_count = 1 - def init_environment(self): """Any changes we need to make to the user's environment.""" pass @@ -2066,27 +2069,6 @@ class InteractiveShell(Configurable, Magic): cell : str A single or multiline string. """ - ################################################################# - # FIXME - # ===== - # This execution logic should stop calling runlines altogether, and - # instead we should do what runlines does, in a controlled manner, here - # (runlines mutates lots of state as it goes calling sub-methods that - # also mutate state). Basically we should: - # - apply dynamic transforms for single-line input (the ones that - # split_blocks won't apply since they need context). - # - increment the global execution counter (we need to pull that out - # from outputcache's control; outputcache should instead read it from - # the main object). - # - do any logging of input - # - update histories (raw/translated) - # - then, call plain run_source (for single blocks, so displayhook is - # triggered) or run_code (for multiline blocks in exec mode). - # - # Once this is done, we'll be able to stop using runlines and we'll - # also have a much cleaner separation of logging, input history and - # output cache management. - ################################################################# # We need to break up the input into executable blocks that can be run # in 'single' mode, to provide comfortable user behavior. diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index d15af47..3ddd9bb 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -161,7 +161,7 @@ def test_shist(): tfile = tempfile.mktemp('','tmp-ipython-') db = pickleshare.PickleShareDB(tfile) - s = ShadowHist(db) + s = ShadowHist(db, get_ipython()) s.add('hello') s.add('world') s.add('hello')