Show More
@@ -20,7 +20,6 b' import sys' | |||
|
20 | 20 | # Our own packages |
|
21 | 21 | import IPython.utils.io |
|
22 | 22 | |
|
23 | from IPython.core import ipapi | |
|
24 | 23 | from IPython.core.inputlist import InputList |
|
25 | 24 | from IPython.utils.pickleshare import PickleShareDB |
|
26 | 25 | from IPython.utils.io import ask_yes_no |
@@ -118,7 +117,7 b' class HistoryManager(object):' | |||
|
118 | 117 | print(r"only has ASCII characters, e.g. c:\home") |
|
119 | 118 | print("Now it is", self.ipython_dir) |
|
120 | 119 | sys.exit() |
|
121 | self.shadow_hist = ShadowHist(self.shadow_db) | |
|
120 | self.shadow_hist = ShadowHist(self.shadow_db, self.shell) | |
|
122 | 121 | |
|
123 | 122 | def save_hist(self): |
|
124 | 123 | """Save input history to a file (via readline library).""" |
@@ -456,11 +455,12 b' def rep_f(self, arg):' | |||
|
456 | 455 | _sentinel = object() |
|
457 | 456 | |
|
458 | 457 | class ShadowHist(object): |
|
459 | def __init__(self, db): | |
|
458 | def __init__(self, db, shell): | |
|
460 | 459 | # cmd => idx mapping |
|
461 | 460 | self.curidx = 0 |
|
462 | 461 | self.db = db |
|
463 | 462 | self.disabled = False |
|
463 | self.shell = shell | |
|
464 | 464 | |
|
465 | 465 | def inc_idx(self): |
|
466 | 466 | idx = self.db.get('shadowhist_idx', 1) |
@@ -478,7 +478,7 b' class ShadowHist(object):' | |||
|
478 | 478 | #print("new", newidx) # dbg |
|
479 | 479 | self.db.hset('shadowhist',ent, newidx) |
|
480 | 480 | except: |
|
481 |
|
|
|
481 | self.shell.showtraceback() | |
|
482 | 482 | print("WARNING: disabling shadow history") |
|
483 | 483 | self.disabled = True |
|
484 | 484 |
@@ -154,6 +154,8 b' class InteractiveShell(Configurable, Magic):' | |||
|
154 | 154 | deep_reload = CBool(False, config=True) |
|
155 | 155 | displayhook_class = Type(DisplayHook) |
|
156 | 156 | exit_now = CBool(False) |
|
157 | # Monotonically increasing execution counter | |
|
158 | execution_count = Int(1) | |
|
157 | 159 | filename = Str("<ipython console>") |
|
158 | 160 | ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__ |
|
159 | 161 | |
@@ -370,6 +372,10 b' class InteractiveShell(Configurable, Magic):' | |||
|
370 | 372 | self.compile = codeop.CommandCompiler() |
|
371 | 373 | |
|
372 | 374 | # User input buffers |
|
375 | # NOTE: these variables are slated for full removal, once we are 100% | |
|
376 | # sure that the new execution logic is solid. We will delte runlines, | |
|
377 | # push_line and these buffers, as all input will be managed by the | |
|
378 | # frontends via an inputsplitter instance. | |
|
373 | 379 | self.buffer = [] |
|
374 | 380 | self.buffer_raw = [] |
|
375 | 381 | |
@@ -399,9 +405,6 b' class InteractiveShell(Configurable, Magic):' | |||
|
399 | 405 | # Indentation management |
|
400 | 406 | self.indent_current_nsp = 0 |
|
401 | 407 | |
|
402 | # Increasing execution counter | |
|
403 | self.execution_count = 1 | |
|
404 | ||
|
405 | 408 | def init_environment(self): |
|
406 | 409 | """Any changes we need to make to the user's environment.""" |
|
407 | 410 | pass |
@@ -2066,27 +2069,6 b' class InteractiveShell(Configurable, Magic):' | |||
|
2066 | 2069 | cell : str |
|
2067 | 2070 | A single or multiline string. |
|
2068 | 2071 | """ |
|
2069 | ################################################################# | |
|
2070 | # FIXME | |
|
2071 | # ===== | |
|
2072 | # This execution logic should stop calling runlines altogether, and | |
|
2073 | # instead we should do what runlines does, in a controlled manner, here | |
|
2074 | # (runlines mutates lots of state as it goes calling sub-methods that | |
|
2075 | # also mutate state). Basically we should: | |
|
2076 | # - apply dynamic transforms for single-line input (the ones that | |
|
2077 | # split_blocks won't apply since they need context). | |
|
2078 | # - increment the global execution counter (we need to pull that out | |
|
2079 | # from outputcache's control; outputcache should instead read it from | |
|
2080 | # the main object). | |
|
2081 | # - do any logging of input | |
|
2082 | # - update histories (raw/translated) | |
|
2083 | # - then, call plain run_source (for single blocks, so displayhook is | |
|
2084 | # triggered) or run_code (for multiline blocks in exec mode). | |
|
2085 | # | |
|
2086 | # Once this is done, we'll be able to stop using runlines and we'll | |
|
2087 | # also have a much cleaner separation of logging, input history and | |
|
2088 | # output cache management. | |
|
2089 | ################################################################# | |
|
2090 | 2072 | |
|
2091 | 2073 | # We need to break up the input into executable blocks that can be run |
|
2092 | 2074 | # in 'single' mode, to provide comfortable user behavior. |
General Comments 0
You need to be logged in to leave comments.
Login now