Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Kernel crash with empty history #260

Closed
wants to merge 1 commit into from

1 participant

@takluyver
Owner

Running iptest leaves a completely empty history, without the blank first item used to create an offset. Running ipython-qtconsole then causes the kernel to crash as it receives a history request from the console.

In time, I'd like to do some more general work on the history code, but for now, this fixes the immediate issue so that the kernel doesn't fall over when loading an empty history.

@takluyver
Owner

My more thorough rewrite of the relevant code took less time than I thought. This is superseded by pull request ipython/ipython#261.

@damianavila damianavila referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +5 −2 IPython/core/history.py
View
7 IPython/core/history.py
@@ -105,7 +105,7 @@ def __init__(self, shell):
# Object is fully initialized, we can now call methods on it.
# Fill the history zero entry, user counter starts at 1
- self.store_inputs('\n', '\n')
+ self.store_inputs('', '')
# Create and start the autosaver.
self.autosave_flag = threading.Event()
@@ -169,6 +169,9 @@ def reload_history(self):
return
self.input_hist_parsed = hist['parsed']
self.input_hist_raw = hist['raw']
+ if not self.input_hist_raw:
+ # Fill the history zero entry, user counter starts at 1
+ self.store_inputs('', '')
if self.shell.has_readline:
self.populate_readline_history()
@@ -180,7 +183,7 @@ def get_history(self, index=None, raw=False, output=True):
Parameters
----------
index : n or (n1, n2) or None
- If n, then the last entries. If a tuple, then all in
+ If n, then the last n entries. If a tuple, then all in
range(n1, n2). If None, then all entries. Raises IndexError if
the format of index is incorrect.
raw : bool
Something went wrong with that request. Please try again.