Repository: xonsh/xonsh

Issue:
Out-of-date prompt-toolkit causes `TypeError` crash on start
Since upgrading to 0.2.7, running `xonsh` (with or without `--no-rc`) gives me a `TypeError`:

```
$ xonsh --version
('xonsh/0.2.7',)
$ xonsh --no-rc
/usr/local/lib/python3.4/dist-packages/xonsh/shell.py:97: RuntimeWarning: prompt-toolkit version < v0.57 and may not work as expected. Please update.
  warn(msg, RuntimeWarning)
Traceback (most recent call last):
  File "/usr/local/bin/xonsh", line 9, in <module>
    load_entry_point('xonsh==0.2.7', 'console_scripts', 'xonsh')()
  File "/usr/local/lib/python3.4/dist-packages/xonsh/main.py", line 214, in main
    shell.cmdloop()
  File "/usr/local/lib/python3.4/dist-packages/xonsh/ptk/shell.py", line 112, in cmdloop
    line = self.singleline(auto_suggest=auto_suggest)
  File "/usr/local/lib/python3.4/dist-packages/xonsh/ptk/shell.py", line 81, in singleline
    display_completions_in_columns=multicolumn)
  File "/usr/local/lib/python3.4/dist-packages/xonsh/ptk/shortcuts.py", line 71, in prompt
    application=create_prompt_application(message, **kwargs),
TypeError: create_prompt_application() got an unexpected keyword argument 'reserve_space_for_menu'
```

`xonsh --shell-type readline` starts successfully, so I'm guessing the crash is caused by the prompt-toolkit version. I can't remember how I installed prompt-toolkit, so I'll stick with readline for a bit.

I'm running Ubuntu 14.04 x86_64, kernel 3.16.0-67-generic. `xonsh` is installed system-wide using `pip3`. Feel free to ask for any more information you need.



Discussion:
Thanks for reporting @HarryCutts. This should not be a fatal error.


Resolving patch:
diff --git a/xonsh/ptk/shortcuts.py b/xonsh/ptk/shortcuts.py
--- a/xonsh/ptk/shortcuts.py
+++ b/xonsh/ptk/shortcuts.py
@@ -1,7 +1,7 @@
 """A prompt-toolkit inspired shortcut collection."""
 from prompt_toolkit.interface import CommandLineInterface
 from prompt_toolkit.utils import DummyContext
-from prompt_toolkit.shortcuts import (create_prompt_application, 
+from prompt_toolkit.shortcuts import (create_prompt_application,
     create_eventloop, create_asyncio_eventloop, create_output)
 
 from xonsh.shell import prompt_toolkit_version_info
@@ -9,7 +9,7 @@
 class Prompter(object):
 
     def __init__(self, cli=None, *args, **kwargs):
-        """Implements a prompt that statefully holds a command-line 
+        """Implements a prompt that statefully holds a command-line
         interface.  When used as a context manager, it will return itself
         on entry and reset itself on exit.
 
@@ -33,18 +33,18 @@ def __exit__(self, exc_type, exc_value, traceback):
     def prompt(self, message='', **kwargs):
         """Get input from the user and return it.
 
-        This is a wrapper around a lot of prompt_toolkit functionality and 
-        can be a replacement for raw_input. (or GNU readline.) If you want 
-        to keep your history across several calls, create one 
-        `~prompt_toolkit.history.History instance and pass it every 
-        time. This function accepts many keyword arguments. Except for the 
-        following. they are a proxy to the arguments of 
+        This is a wrapper around a lot of prompt_toolkit functionality and
+        can be a replacement for raw_input. (or GNU readline.) If you want
+        to keep your history across several calls, create one
+        `~prompt_toolkit.history.History instance and pass it every
+        time. This function accepts many keyword arguments. Except for the
+        following. they are a proxy to the arguments of
         create_prompt_application().
 
         Parameters
         ----------
         patch_stdout : file-like, optional
-            Replace ``sys.stdout`` by a proxy that ensures that print 
+            Replace ``sys.stdout`` by a proxy that ensures that print
             statements from other threads won't destroy the prompt. (They
             will be printed above the prompt instead.)
         return_asyncio_coroutine : bool, optional
@@ -64,6 +64,8 @@ def prompt(self, message='', **kwargs):
 
         # Create CommandLineInterface.
         if self.cli is None:
+            if self.major_minor < (0, 57):
+                kwargs.pop('reserve_space_for_menu', None)
             if self.major_minor <= (0, 57):
                 kwargs.pop('get_rprompt_tokens', None)
                 kwargs.pop('get_continuation_tokens', None)
@@ -93,9 +95,9 @@ def prompt_coro():
             '''), exec_context)
             return exec_context['prompt_coro']()
         else:
-            # Note: We pass `reset_current_buffer=False`, because that way 
-            # it's easy to give DEFAULT_BUFFER a default value, without it 
-            # getting erased. We don't have to reset anyway, because this is 
+            # Note: We pass `reset_current_buffer=False`, because that way
+            # it's easy to give DEFAULT_BUFFER a default value, without it
+            # getting erased. We don't have to reset anyway, because this is
             # the first and only time that this CommandLineInterface will run.
             try:
                 with patch_context:
@@ -140,7 +142,7 @@ def create_output(stdout=None, true_color=False):
         This method was forked from the mainline prompt-toolkit repo.
         Copyright (c) 2014, Jonathan Slenders, All rights reserved.
         This is deprecated and slated for removal after a prompt-toolkit
-        v0.57+ release. 
+        v0.57+ release.
         """
         stdout = stdout or sys.__stdout__
         true_color = to_simple_filter(true_color)
@@ -179,7 +181,7 @@ def print_tokens(tokens, style=None, true_color=False):
         This method was forked from the mainline prompt-toolkit repo.
         Copyright (c) 2014, Jonathan Slenders, All rights reserved.
         This is deprecated and slated for removal after a prompt-toolkit
-        v0.57+ release. 
+        v0.57+ release.
         """
         assert isinstance(style, Style)
         output = create_output(true_color=true_color)


Test patch: