Skip to content

"Error in the keymap" when re-entering IPython REPL for the second time #32

Description

@kyak

When entering IPython REPL for the second time, there is an "Error in the keymap" error after entering any command.

Steps to reproduce:

  1. Enter IPython REPL for the first time, issue a command and return to Julia REPL. So far so good:
julia> using IPython

julia> IPython.start_ipython()


In [1]: 1
Out[1]: 1

In [2]:
  1. Enter IPython REPL again, issue a command and observe the error:
julia> IPython.start_ipython()


In [2]: 1
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /usr/lib/python3.10/site-packages/IPython/core/async_helpers.py:129, in _pseudo_sync_runner(coro)
    121 """
    122 A runner that does not really allow async execution, and just advance the coroutine.
    123
   (...)
    126 Credit to Nathaniel Smith
    127 """
    128 try:
--> 129     coro.send(None)
    130 except StopIteration as exc:
    131     return exc.value

File /usr/lib/python3.10/site-packages/IPython/core/interactiveshell.py:3084, in InteractiveShell.run_cell_async(self, raw_cell, store_history, silent, shell_futures, transformed_cell, preprocessing_exc_tuple, cell_id)
   3082 # Store raw and processed history
   3083 if store_history and raw_cell.strip(" %") != "paste":
-> 3084     self.history_manager.store_inputs(self.execution_count, cell, raw_cell)
   3085 if not silent:
   3086     self.logger.log(cell, raw_cell)

AttributeError: 'NoneType' object has no attribute 'store_inputs'

In [2]:

Below is more information about package versions and a more detailed log. The more detailed log is obtained by running IPython via . rather than IPython.start_ipython() (not sure why it's more detailed though). Thank you for this nice package! If you need more information, please let me know.

julia: v1.7.3
IPython.jl: v0.5.1
python: v3.10.5
ipython: v8.4.0
OS: Arch Linux

In [2]: 1 + 2
Press ENTER to continue...
Unhandled exception in event loop:
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/input/vt100.py", line 173, in callback_wrapper
    callback()
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 711, in read_from_input
    self.key_processor.process_keys()
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 270, in process_keys
    self._process_coroutine.send(key_press)
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 185, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 320, in _call_handler
    handler.call(event)
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 124, in call
    result = self.handler(event)
  File "/usr/lib/python3.10/site-packages/IPython/terminal/shortcuts.py", line 412, in newline_or_execute
    b.validate_and_handle()
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/buffer.py", line 1880, in validate_and_handle
    self.append_to_history()
  File "/usr/lib/python3.10/site-packages/prompt_toolkit/buffer.py", line 1386, in append_to_history
    self.history.append_string(self.text)
  File "/usr/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 148, in append_string
    self._refresh()
  File "/usr/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 152, in _refresh
    self._loaded_strings = list(self.load_history_strings())
  File "/usr/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 157, in load_history_strings
    for __, ___, cell in self.shell.history_manager.get_tail(

Exception 'NoneType' object has no attribute 'get_tail'
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /usr/lib/python3.10/site-packages/IPython/core/async_helpers.py:129, in _pseudo_sync_runner(coro)
    121 """
    122 A runner that does not really allow async execution, and just advance the coroutine.
    123
   (...)
    126 Credit to Nathaniel Smith
    127 """
    128 try:
--> 129     coro.send(None)
    130 except StopIteration as exc:
    131     return exc.value

File /usr/lib/python3.10/site-packages/IPython/core/interactiveshell.py:3084, in InteractiveShell.run_cell_async(self, raw_cell, store_history, silent, shell_futures, transformed_cell, preprocessing_exc_tuple, cell_id)
   3082 # Store raw and processed history
   3083 if store_history and raw_cell.strip(" %") != "paste":
-> 3084     self.history_manager.store_inputs(self.execution_count, cell, raw_cell)
   3085 if not silent:
   3086     self.logger.log(cell, raw_cell)

AttributeError: 'NoneType' object has no attribute 'store_inputs'

In [2]: ┌ Error: Error in the keymap
│   exception =
│    PyCall.PyError("\$(Expr(:escape, :(ccall(#= /home/peselnikmg/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))", PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00007f552c3e5ce0), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00007f5517b5f830), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x00007f55176c8140))
│    Stacktrace:
│      [1] pyerr_check
│        @ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:62 [inlined]
│      [2] pyerr_check
│        @ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:66 [inlined]
│      [3] _handle_error(msg::String)
│        @ PyCall ~/.julia/packages/PyCall/7a7w0/src/exception.jl:83
│      [4] macro expansion
│        @ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:97 [inlined]
│      [5] #107
│        @ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 [inlined]
│      [6] disable_sigint
│        @ ./c.jl:458 [inlined]
│      [7] __pycall!
│        @ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:42 [inlined]
│      [8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{PyCall.PyObject, PyCall.PyObject}, nargs::Int64, kw::Ptr{Nothing})
│        @ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:29
│      [9] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{PyCall.PyObject, PyCall.PyObject}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:11
│     [10] pycall(::PyCall.PyObject, ::Type{Nothing}, ::PyCall.PyObject, ::Vararg{PyCall.PyObject}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:80
│     [11] pycall(::PyCall.PyObject, ::Type{Nothing}, ::PyCall.PyObject, ::Vararg{PyCall.PyObject})
│        @ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:80
│     [12] _start_ipython(f::PyCall.PyObject, returntype::Type) (repeats 2 times)
│        @ IPython ~/.julia/packages/IPython/hdHop/src/core.jl:39
│     [13] start_ipython
│        @ ~/.julia/packages/IPython/hdHop/src/core.jl:46 [inlined]
│     [14] on_dot_press(::REPL.LineEdit.MIState, ::REPL.LineEditREPL, ::Vararg{Any})
│        @ IPython ~/.julia/packages/IPython/hdHop/src/julia_repl.jl:49
│     [15] #invokelatest#2
│        @ ./essentials.jl:716 [inlined]
│     [16] invokelatest
│        @ ./essentials.jl:714 [inlined]
│     [17] (::REPL.LineEdit.var"#25#26"{typeof(IPython.on_dot_press), String})(s::Any, p::Any)
│        @ REPL.LineEdit /usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:1466
│     [18] (::REPL.LineEdit.var"#242#250")(s::REPL.LineEdit.MIState, data::REPL.LineEdit.ModeState, c::Union{Char, SubString{String}, String})
│        @ REPL.LineEdit /usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2356
│     [19] #invokelatest#2
│        @ ./essentials.jl:716 [inlined]
│     [20] invokelatest
│        @ ./essentials.jl:714 [inlined]
│     [21] (::REPL.LineEdit.var"#25#26"{REPL.LineEdit.var"#242#250", String})(s::Any, p::Any)
│        @ REPL.LineEdit /usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:1466
│     [22] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2586
│     [23] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2488
│     [24] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL /usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:1232
│     [25] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL ./task.jl:429
└ @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2588

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions