Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powerline-status crashes with ipython>=7.0.0 #1953

Closed
dylon opened this issue Oct 5, 2018 · 42 comments · Fixed by #1997
Closed

powerline-status crashes with ipython>=7.0.0 #1953

dylon opened this issue Oct 5, 2018 · 42 comments · Fixed by #1997
Assignees

Comments

@dylon
Copy link

dylon commented Oct 5, 2018

The Powerline plugin for IPython causes it to crash on startup for versions 7.0.0 and 7.0.1; it works well for IPython version 6.5.0. I will attach the detailed crash report as a comment. Below is my IPython configuration:

# Enable the Powerline prompt
from powerline.bindings.ipython.since_5 import PowerlinePrompts
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts

## Shortcut style to use at the prompt. 'vi' or 'emacs'.
c.TerminalInteractiveShell.editing_mode = 'vi'

## Set the editor used by IPython (default to $EDITOR/vi/notepad).
c.TerminalInteractiveShell.editor = 'vim'

c.TerminalInteractiveShell.highlighting_style = 'monokai'
@dylon
Copy link
Author

dylon commented Oct 5, 2018

$ ipython                                                                                                                                                            master| ✔
Python 3.6.6 (default, Oct  3 2018, 13:39:52)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.1 -- An enhanced Interactive Python. Type '?' for help.

---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeErrorPython 3.6.6: /home/local/ANT/dylone/.pyenv/versions/3.6.6/bin/python3.6
                                                   Fri Oct  5 12:15:31 2018
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async2()
    650                     f = From(_run_async())
--> 651                     result = yield f
        result = undefined
        f = <prompt_toolkit.eventloop.future.Future object at 0x7f06ce70c240>
    652                 finally:

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py in step_next(f=None)
     85             if f is None:
---> 86                 new_f = coroutine.send(None)
        global new_f = undefined
        global coroutine.send = undefined
     87             else:

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async()
    593                     self._request_absolute_cursor_position()
--> 594                     self._redraw()
        global self._redraw = undefined
    595

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _redraw(self=<prompt_toolkit.application.application.Application object>, render_as_done=False)
    442                 else:
--> 443                     self.renderer.render(self, self.layout)
        self.renderer.render = <bound method Renderer.render of <prompt_toolkit.renderer.Renderer object at 0x7f06ce5eb320>>
        self = <prompt_toolkit.application.application.Application object at 0x7f06ce749710>
        self.layout = Layout(<prompt_toolkit.layout.containers.HSplit object at 0x7f06ce736e48>, current_window=Window(content=<BufferControl buffer=<Buffer(name='DEFAULT_BUFFER', text='') at 139667210131160> at 139667210247472>))
    444

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/renderer.py in render(self=<prompt_toolkit.renderer.Renderer object>, app=<prompt_toolkit.application.application.Application object>, layout=Layout(<prompt_toolkit.layout.containers.HSplit ...ext='') at 139667210131160> at 139667210247472>)), is_done=False)
    549         # (But note that we still use _last_screen to calculate the height.)
--> 550         if (self.style.invalidation_hash() != self._last_style_hash or
        self.style.invalidation_hash = <bound method _MergedStyle.invalidation_hash of <prompt_toolkit.styles.style._MergedStyle object at 0x7f06ce5eb208>>
        self._last_style_hash = None
        app.style_transformation.invalidation_hash = <bound method _MergedStyleTransformation.invalidation_hash of <prompt_toolkit.styles.style_transformation._MergedStyleTransformation object at 0x7f06ce7490b8>>
        self._last_transformation_hash = None
        app.color_depth = 'DEPTH_8_BIT'
        self._last_color_depth = None
    551                 app.style_transformation.invalidation_hash() != self._last_transformation_hash or

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/style.py in invalidation_hash(self=<prompt_toolkit.styles.style._MergedStyle object>)
    371     def invalidation_hash(self):
--> 372         return tuple(s.invalidation_hash() for s in self.styles)
        global tuple = undefined
        global s.invalidation_hash = undefined
        global s = undefined
        self.styles = [<prompt_toolkit.styles.style._MergedStyle object at 0x7f06ce6538d0>, <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce63ea90>, <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce5eb2b0>]

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/style.py in <genexpr>(.0=<list_iterator object>)
    371     def invalidation_hash(self):
--> 372         return tuple(s.invalidation_hash() for s in self.styles)
        global tuple = undefined
        s.invalidation_hash = <bound method DynamicStyle.invalidation_hash of <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce5eb2b0>>
        s = <prompt_toolkit.styles.base.DynamicStyle object at 0x7f06ce5eb2b0>
        global self.styles = undefined

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/base.py in invalidation_hash(self=<prompt_toolkit.styles.base.DynamicStyle object>)
    139     def invalidation_hash(self):
--> 140         return (self.get_style() or self._dummy).invalidation_hash()
        self.get_style = <function Application._create_merged_style.<locals>.<lambda> at 0x7f06ce63b730>
        self._dummy.invalidation_hash = <bound method DummyStyle.invalidation_hash of <prompt_toolkit.styles.base.DummyStyle object at 0x7f06ce5eb278>>
    141

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/base.py in invalidation_hash(self=<prompt_toolkit.styles.base.DynamicStyle object>)
    139     def invalidation_hash(self):
--> 140         return (self.get_style() or self._dummy).invalidation_hash()
        self.get_style = <function PromptSession._create_application.<locals>.<lambda> at 0x7f06ce660598>
        self._dummy.invalidation_hash = <bound method DummyStyle.invalidation_hash of <prompt_toolkit.styles.base.DummyStyle object at 0x7f06ce748e80>>
    141

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/styles/base.py in invalidation_hash(self=<prompt_toolkit.styles.base.DynamicStyle object>)
    139     def invalidation_hash(self):
--> 140         return (self.get_style() or self._dummy).invalidation_hash()
        self.get_style = <function TerminalInteractiveShell.init_prompt_toolkit_cli.<locals>.<lambda> at 0x7f06ce832bf8>
        self._dummy.invalidation_hash = <bound method DummyStyle.invalidation_hash of <prompt_toolkit.styles.base.DummyStyle object at 0x7f06ce821630>>
    141

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/powerline/renderers/ipython/since_5.py in invalidation_hash(self=<powerline.renderers.ipython.since_5.PowerlinePromptStyle object>)
     78         def invalidation_hash(self):
---> 79                 return super(PowerlinePromptStyle, self).invalidation_hash() + 1
        global super = undefined
        global PowerlinePromptStyle = <class 'powerline.renderers.ipython.since_5.PowerlinePromptStyle'>
        self.invalidation_hash = <bound method PowerlinePromptStyle.invalidation_hash of <powerline.renderers.ipython.since_5.PowerlinePromptStyle object at 0x7f06ce5f8cf8>>
     80

TypeError: can only concatenate tuple (not "int") to tuple

During handling of the above exception, another exception occurred:

---------------------------------------------------------------------------
AssertionErrorPython 3.6.6: /home/local/ANT/dylone/.pyenv/versions/3.6.6/bin/python3.6
                                                   Fri Oct  5 12:15:31 2018
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
~/.pyenv/versions/3.6.6/bin/ipython in <module>
      1 #!/home/local/ANT/dylone/.pyenv/versions/3.6.6/bin/python3.6
      2
      3 # -*- coding: utf-8 -*-
      4 import re
      5 import sys
      6
      7 from IPython import start_ipython
      8
      9 if __name__ == '__main__':
     10     sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
---> 11     sys.exit(start_ipython())
        global sys.exit = <built-in function exit>
        global start_ipython = <function start_ipython at 0x7f06cf554378>

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/__init__.py in start_ipython(argv=None, **kwargs={})
    110     This is a public API method, and will survive implementation changes.
    111
    112     Parameters
    113     ----------
    114
    115     argv : list or None, optional
    116         If unspecified or None, IPython will parse command-line options from sys.argv.
    117         To prevent any command-line parsing, pass an empty list: `argv=[]`.
    118     user_ns : dict, optional
    119         specify this dictionary to initialize the IPython user namespace with particular values.
    120     kwargs : various, optional
    121         Any other kwargs will be passed to the Application constructor,
    122         such as `config`.
    123     """
    124     from IPython.terminal.ipapp import launch_new_instance
--> 125     return launch_new_instance(argv=argv, **kwargs)
        launch_new_instance = <bound method Application.launch_instance of <class 'IPython.terminal.ipapp.TerminalIPythonApp'>>
        argv = None
        kwargs = {}
    126
    127 def start_kernel(argv=None, **kwargs):
    128     """Launch a normal IPython kernel instance (as opposed to embedded)
    129
    130     `IPython.embed_kernel()` puts a shell in a particular calling scope,
    131     such as a function or method for debugging purposes,
    132     which is often not desirable.
    133
    134     `start_kernel()` does full, regular IPython initialization,
    135     including loading startup files, configuration, etc.
    136     much of which is skipped by `embed()`.
    137
    138     Parameters
    139     ----------
    140

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'IPython.terminal.ipapp.TerminalIPythonApp'>, argv=None, **kwargs={})
    643             lines.append(cls.class_config_section())
    644         return '\n'.join(lines)
    645
    646     def exit(self, exit_status=0):
    647         self.log.debug("Exiting application: %s" % self.name)
    648         sys.exit(exit_status)
    649
    650     @classmethod
    651     def launch_instance(cls, argv=None, **kwargs):
    652         """Launch a global instance of this Application
    653
    654         If a global instance already exists, this reinitializes and starts it
    655         """
    656         app = cls.instance(**kwargs)
    657         app.initialize(argv)
--> 658         app.start()
        app.start = <bound method TerminalIPythonApp.start of <IPython.terminal.ipapp.TerminalIPythonApp object at 0x7f06d6aae080>>
    659
    660 #-----------------------------------------------------------------------------
    661 # utility functions, for convenience
    662 #-----------------------------------------------------------------------------
    663
    664 def boolean_flag(name, configurable, set_help='', unset_help=''):
    665     """Helper for building basic --trait, --no-trait flags.
    666
    667     Parameters
    668     ----------
    669
    670     name : str
    671         The name of the flag.
    672     configurable : str
    673         The 'Class.trait' string of the trait to be set/unset with the flag

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/ipapp.py in start(self=<IPython.terminal.ipapp.TerminalIPythonApp object>)
    341         if self.log_level <= logging.INFO: print()
    342
    343     def _pylab_changed(self, name, old, new):
    344         """Replace --pylab='inline' with --pylab='auto'"""
    345         if new == 'inline':
    346             warnings.warn("'inline' not available as pylab backend, "
    347                       "using 'auto' instead.")
    348             self.pylab = 'auto'
    349
    350     def start(self):
    351         if self.subapp is not None:
    352             return self.subapp.start()
    353         # perform any prexec steps:
    354         if self.interact:
    355             self.log.debug("Starting IPython's mainloop...")
--> 356             self.shell.mainloop()
        self.shell.mainloop = <bound method TerminalInteractiveShell.mainloop of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
    357         else:
    358             self.log.debug("IPython not interactive...")
    359             if not self.shell.last_execution_succeeded:
    360                 sys.exit(1)
    361
    362 def load_default_config(ipython_dir=None):
    363     """Load the default config file from the default ipython_dir.
    364
    365     This is useful for embedded shells.
    366     """
    367     if ipython_dir is None:
    368         ipython_dir = get_ipython_dir()
    369
    370     profile_dir = os.path.join(ipython_dir, 'profile_default')
    371     app = TerminalIPythonApp()

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in mainloop(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
    457                 if (not self.confirm_exit) \
    458                         or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
    459                     self.ask_exit()
    460
    461             else:
    462                 if code:
    463                     self.run_cell(code, store_history=True)
    464
    465     def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    466         # An extra layer of protection in case someone mashing Ctrl-C breaks
    467         # out of our internal code.
    468         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    469             warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
    470         while True:
    471             try:
--> 472                 self.interact()
        self.interact = <bound method TerminalInteractiveShell.interact of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
    473                 break
    474             except KeyboardInterrupt as e:
    475                 print("\n%s escaped interact()\n" % type(e).__name__)
    476             finally:
    477                 # An interrupt during the eventloop will mess up the
    478                 # internal state of the prompt_toolkit library.
    479                 # Stopping the eventloop fixes this, see
    480                 # https://github.com/ipython/ipython/pull/9867
    481                 if hasattr(self, '_eventloop'):
    482                     self._eventloop.stop()
    483
    484     _inputhook = None
    485     def inputhook(self, context):
    486         if self._inputhook is not None:
    487             self._inputhook(context)

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in interact(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
    440     def ask_exit(self):
    441         self.keep_running = False
    442
    443     rl_next_input = None
    444
    445     def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    446
    447         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    448             warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
    449
    450         self.keep_running = True
    451         while self.keep_running:
    452             print(self.separate_in, end='')
    453
    454             try:
--> 455                 code = self.prompt_for_code()
        code = undefined
        self.prompt_for_code = <bound method TerminalInteractiveShell.prompt_for_code of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
    456             except EOFError:
    457                 if (not self.confirm_exit) \
    458                         or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
    459                     self.ask_exit()
    460
    461             else:
    462                 if code:
    463                     self.run_cell(code, store_history=True)
    464
    465     def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
    466         # An extra layer of protection in case someone mashing Ctrl-C breaks
    467         # out of our internal code.
    468         if display_banner is not DISPLAY_BANNER_DEPRECATED:
    469             warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
    470         while True:

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py in prompt_for_code(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>)
    369                             Condition(lambda: self.highlight_matching_brackets))],
    370                 'inputhook': self.inputhook,
    371                 }
    372
    373     def prompt_for_code(self):
    374         if self.rl_next_input:
    375             default = self.rl_next_input
    376             self.rl_next_input = None
    377         else:
    378             default = ''
    379
    380         with patch_stdout(raw=True):
    381             text = self.pt_app.prompt(
    382                 default=default,
    383 #                pre_run=self.pre_prompt,# reset_current_buffer=True,
--> 384                 **self._extra_prompt_options())
        self._extra_prompt_options = <bound method TerminalInteractiveShell._extra_prompt_options of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f06d25a8a20>>
    385         return text
    386
    387     def enable_win_unicode_console(self):
    388         if sys.version_info >= (3, 6):
    389             # Since PEP 528, Python uses the unicode APIs for the Windows
    390             # console by default, so WUC shouldn't be needed.
    391             return
    392
    393         import win_unicode_console
    394         win_unicode_console.enable()
    395
    396     def init_io(self):
    397         if sys.platform not in {'win32', 'cli'}:
    398             return
    399

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py in prompt(self=<prompt_toolkit.shortcuts.prompt.PromptSession object>, message=<function TerminalInteractiveShell._extra_prompt_options.<locals>.get_message>, default='', editing_mode=None, refresh_interval=None, vi_mode=None, lexer=<IPython.terminal.ptutils.IPythonPTLexer object>, completer=None, complete_in_thread=False, is_password=None, key_bindings=None, bottom_toolbar=None, style=None, color_depth=None, include_default_pygments_style=None, style_transformation=None, swap_light_and_dark_colors=None, rprompt=None, multiline=True, prompt_continuation=<function TerminalInteractiveShell._extra_prompt_options.<locals>.<lambda>>, wrap_lines=None, enable_history_search=None, search_ignore_case=None, complete_while_typing=None, validate_while_typing=None, complete_style='MULTI_COLUMN', auto_suggest=None, validator=None, clipboard=None, mouse_support=None, input_processors=[ConditionalProcessor(processor=<prompt_toolkit.l...pt_options.<locals>.<lambda> at 0x7f06ce63bea0>))], reserve_space_for_menu=6, enable_system_prompt=None, enable_suspend=None, enable_open_in_editor=None, tempfile_suffix=None, inputhook=<bound method TerminalInteractiveShell.inputhook...nteractiveshell.TerminalInteractiveShell object>>, async_=False, accept_default=False, pre_run=None)
    716
    717         def run_sync():
    718             with self._auto_refresh_context():
    719                 self.default_buffer.reset(Document(self.default))
    720                 return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
    721
    722         def run_async():
    723             with self._auto_refresh_context():
    724                 self.default_buffer.reset(Document(self.default))
    725                 result = yield From(self.app.run_async(pre_run=pre_run2))
    726                 raise Return(result)
    727
    728         if async_:
    729             return ensure_future(run_async())
    730         else:
--> 731             return run_sync()
        run_sync = <function PromptSession.prompt.<locals>.run_sync at 0x7f06ce832c80>
    732
    733     @property
    734     def editing_mode(self):
    735         return self.app.editing_mode
    736
    737     @editing_mode.setter
    738     def editing_mode(self, value):
    739         self.app.editing_mode = value
    740
    741     def _get_default_buffer_control_height(self):
    742         # If there is an autocompletion menu to be shown, make sure that our
    743         # layout has at least a minimal height in order to display it.
    744         if (self.completer is not None and
    745                 self.complete_style != CompleteStyle.READLINE_LIKE):
    746             space = self.reserve_space_for_menu

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py in run_sync()
    705         def pre_run2():
    706             if pre_run:
    707                 pre_run()
    708
    709             if accept_default:
    710                 # Validate and handle input. We use `call_from_executor` in
    711                 # order to run it "soon" (during the next iteration of the
    712                 # event loop), instead of right now. Otherwise, it won't
    713                 # display the default value.
    714                 get_event_loop().call_from_executor(
    715                     self.default_buffer.validate_and_handle)
    716
    717         def run_sync():
    718             with self._auto_refresh_context():
    719                 self.default_buffer.reset(Document(self.default))
--> 720                 return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
        global self.app.run = undefined
        global inputhook = undefined
        global self.inputhook = undefined
        global pre_run = undefined
        global pre_run2 = undefined
    721
    722         def run_async():
    723             with self._auto_refresh_context():
    724                 self.default_buffer.reset(Document(self.default))
    725                 result = yield From(self.app.run_async(pre_run=pre_run2))
    726                 raise Return(result)
    727
    728         if async_:
    729             return ensure_future(run_async())
    730         else:
    731             return run_sync()
    732
    733     @property
    734     def editing_mode(self):
    735         return self.app.editing_mode

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in run(self=<prompt_toolkit.application.application.Application object>, pre_run=<function PromptSession.prompt.<locals>.pre_run2>, set_exception_handler=True, inputhook=<bound method TerminalInteractiveShell.inputhook...nteractiveshell.TerminalInteractiveShell object>>)
    683             def print_exception():
    684                 # Print output. Similar to 'loop.default_exception_handler',
    685                 # but don't use logger. (This works better on Python 2.)
    686                 print('\nUnhandled exception in event loop:')
    687                 print(formatted_tb)
    688                 print('Exception %s' % (context.get('exception'), ))
    689
    690                 yield From(_do_wait_for_enter('Press ENTER to continue...'))
    691             run_coroutine_in_terminal(print_exception)
    692
    693         if set_exception_handler:
    694             # Run with patched exception handler.
    695             previous_exc_handler = loop.get_exception_handler()
    696             loop.set_exception_handler(handle_exception)
    697             try:
--> 698                 return run()
        run = <function Application.run.<locals>.run at 0x7f06ce5f9158>
    699             finally:
    700                 loop.set_exception_handler(previous_exc_handler)
    701         else:
    702             run()
    703
    704     def cpr_not_supported_callback(self):
    705         """
    706         Called when we don't receive the cursor position response in time.
    707         """
    708         if not self.input.responds_to_cpr:
    709             return  # We know about this already.
    710
    711         def in_terminal():
    712             self.output.write(
    713                 "WARNING: your terminal doesn't support cursor position requests (CPR).\r\n")

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in run()
    657
    658     def run(self, pre_run=None, set_exception_handler=True, inputhook=None):
    659         """
    660         A blocking 'run' call that waits until the UI is finished.
    661
    662         :param set_exception_handler: When set, in case of an exception, go out
    663             of the alternate screen and hide the application, display the
    664             exception, and wait for the user to press ENTER.
    665         :param inputhook: None or a callable that takes an `InputHookContext`.
    666         """
    667         loop = get_event_loop()
    668
    669         def run():
    670             f = self.run_async(pre_run=pre_run)
    671             run_until_complete(f, inputhook=inputhook)
--> 672             return f.result()
        f.result = <bound method Future.result of <prompt_toolkit.eventloop.future.Future object at 0x7f06ce718978>>
    673
    674         def handle_exception(context):
    675             " Print the exception, using run_in_terminal. "
    676             # For Python 2: we have to get traceback at this point, because
    677             # we're still in the 'except:' block of the event loop where the
    678             # traceback is still available. Moving this code in the
    679             # 'print_exception' coroutine will loose the exception.
    680             tb = get_traceback_from_context(context)
    681             formatted_tb = ''.join(format_tb(tb))
    682
    683             def print_exception():
    684                 # Print output. Similar to 'loop.default_exception_handler',
    685                 # but don't use logger. (This works better on Python 2.)
    686                 print('\nUnhandled exception in event loop:')
    687                 print(formatted_tb)

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/eventloop/future.py in result(self=<prompt_toolkit.eventloop.future.Future object>)
    134             # Activate the original task context (and application) again.
    135             with context(self._ctx_id):
    136                 # They should be called in order.
    137                 for cb in done_callbacks:
    138                     cb(self)
    139
    140         self.loop.call_from_executor(call_them_all)
    141
    142     def result(self):
    143         " Return the result this future represents. "
    144         if not self._done:
    145             raise InvalidStateError
    146
    147         self._retrieved_result = True
    148         if self._exception:
--> 149             raise self._exception
        self._exception = AssertionError()
    150         else:
    151             return self._result
    152
    153     def exception(self):
    154         " Return the exception that was set on this future. "
    155         if not self._done:
    156             raise InvalidStateError
    157
    158         self._retrieved_result = True
    159         return self._exception
    160
    161     def done(self):
    162         """
    163         Return True if the future is done. Done means either that a result /
    164         exception are available, or that the future was cancelled.

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py in step_next(f=<prompt_toolkit.eventloop.future.Future object>)
     75     # (If `step_next` had a direct reference to `result_f` and there is a
     76     # future that references `step_next`, then sometimes it won't be cleaned up
     77     # immediately. - I'm not sure how exactly, but in that case it requires the
     78     # garbage collector, because refcounting isn't sufficient.)
     79     ref = _FutureRef(result_f)
     80
     81     # Loop through the generator.
     82     def step_next(f=None):
     83         " Execute next step of the coroutine."
     84         try:
     85             if f is None:
     86                 new_f = coroutine.send(None)
     87             else:
     88                 exc = f.exception()
     89                 if exc:
---> 90                     new_f = coroutine.throw(exc)
        global new_f = undefined
        global coroutine.throw = undefined
        exc = TypeError('can only concatenate tuple (not "int") to tuple',)
     91                 else:
     92                     new_f = coroutine.send(f.result())
     93         except StopIteration as e:
     94             # Stop coroutine. Make sure that a result has been set in the future,
     95             # this will call the callbacks. (Also, don't take any result from
     96             # StopIteration, it has already been set using `raise Return()`.
     97             if not ref.future.done():
     98                 ref.future.set_result(None)
     99                 ref.forget()
    100         except Return as e:
    101             ref.future.set_result(e.value)
    102             ref.forget()
    103         except BaseException as e:
    104             ref.future.set_exception(e)
    105             ref.forget()

~/.pyenv/versions/3.6.6/lib/python3.6/site-packages/prompt_toolkit/application/application.py in _run_async2()
    638                             if previous_run_in_terminal_f:
    639                                 yield From(previous_run_in_terminal_f)
    640
    641                             # Store unprocessed input as typeahead for next time.
    642                             store_typeahead(self.input, self.key_processor.empty_queue())
    643
    644                 raise Return(result)
    645
    646         def _run_async2():
    647             self._is_running = True
    648             with set_app(self):
    649                 try:
    650                     f = From(_run_async())
    651                     result = yield f
    652                 finally:
--> 653                     assert not self._is_running
        global self._is_running = undefined
    654                 raise Return(result)
    655
    656         return ensure_future(_run_async2())
    657
    658     def run(self, pre_run=None, set_exception_handler=True, inputhook=None):
    659         """
    660         A blocking 'run' call that waits until the UI is finished.
    661
    662         :param set_exception_handler: When set, in case of an exception, go out
    663             of the alternate screen and hide the application, display the
    664             exception, and wait for the user to press ENTER.
    665         :param inputhook: None or a callable that takes an `InputHookContext`.
    666         """
    667         loop = get_event_loop()
    668

AssertionError:

**********************************************************************

Oops, ipython crashed. We do our best to make it stable, but...

A crash report was automatically generated with the following information:
  - A verbatim copy of the crash traceback.
  - A copy of your input history during this session.
  - Data on your current ipython configuration.

It was left in the file named:
        '/home/local/ANT/dylone/.ipython/Crash_report_ipython.txt'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.

You can mail it to: The IPython Development Team at ipython-dev@python.org
with the subject 'ipython Crash Report'.

If you want to do it now, the following command will work (under Unix):
mail -s 'ipython Crash Report' ipython-dev@python.org < /home/local/ANT/dylone/.ipython/Crash_report_ipython.txt

In your email, please also include information about:
- The operating system under which the crash happened: Linux, macOS, Windows,
  other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2,
  Windows 10 Pro), and whether it is 32-bit or 64-bit;
- How ipython was installed: using pip or conda, from GitHub, as part of
  a Docker container, or other, providing more detail if possible;
- How to reproduce the crash: what exact sequence of instructions can one
  input to get the same crash? Ideally, find a minimal yet complete sequence
  of instructions that yields the crash.

To ensure accurate tracking of this issue, please file a report about it at:
https://github.com/ipython/ipython/issues

Hit <Enter> to quit (your terminal may close):
[1]    16729 exit 1     ipython

@Zebradil
Copy link

Zebradil commented Oct 7, 2018

Also crashes with the default configurations from the docs:

from powerline.bindings.ipython.since_5 import PowerlinePrompts
c = get_config()
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts

Exception:

Traceback (most recent call last):
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 635, in _run_async2
    result = yield f
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
    new_f = coroutine.send(None)
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 587, in _run_async
    self._redraw()
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 436, in _redraw
    self.renderer.render(self, self.layout)
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/renderer.py", line 535, in render
    if (self.style.invalidation_hash() != self._last_style_hash or
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/style.py", line 371, in invalidation_hash
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/style.py", line 371, in <genexpr>
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/base.py", line 140, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/base.py", line 140, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/local/Cellar/ipython/7.0.1/libexec/vendor/lib/python3.7/site-packages/prompt_toolkit/styles/base.py", line 140, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/local/lib/python3.7/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash
    return super(PowerlinePromptStyle, self).invalidation_hash() + 1
TypeError: can only concatenate tuple (not "int") to tuple

@Zebradil
Copy link

Zebradil commented Oct 7, 2018

So
ipython>=7.0.0 uses prompt_toolkit>=2.0.0,<2.1.0
ipython<7.0.0 uses prompt_toolkit>=1.0.15,<2.0.0

In prompt_toolkit<2.0.0 invalidation_hash always returns str or int, but in the last versions it might return also tuple.

@Zebradil
Copy link

Zebradil commented Oct 7, 2018

As a workaround I use this:

diff --git a/powerline/renderers/ipython/since_5.py b/powerline/renderers/ipython/since_5.py
index 8a26da72..6719fd09 100644
--- a/powerline/renderers/ipython/since_5.py
+++ b/powerline/renderers/ipython/since_5.py
@@ -76,7 +76,7 @@ class PowerlinePromptStyle(DynamicStyle):
                return PowerlineStyleDict(fallback)

        def invalidation_hash(self):
-           return super(PowerlinePromptStyle, self).invalidation_hash() + 1
+         return (h + 1 for h in tuple(super(PowerlinePromptStyle, self).invalidation_hash()))


 class IPythonPygmentsRenderer(IPythonRenderer):

However, I'm not sure it worth to crate a PR with this. It doesn't look neat.

@martsa1
Copy link

martsa1 commented Oct 10, 2018

Would it be worth creating a since_7.py type file with an appropriate fix in it?

@joelfrederico
Copy link

Could this be done? This is preventing me from using Powerline.

@rharish101
Copy link

The fix mentioned above makes powerline not crash, but doesn't fix it. As in, the prompt displayed is ugly, with "&" being shown wherever the colour is supposed to change.

@PH111P
Copy link
Member

PH111P commented Dec 18, 2018

The & characters seem to be non-breaking space (\xa0); disabling them via the theme config replaces them with normal spaces. However, the colors still don't seem to change and everything has transparent background and #00005f as foreground color.

@GHPS
Copy link

GHPS commented Mar 27, 2019

I can confirm that powerline is broken for the current versions of iPython (7.4 in my case).
The suggested fix by @Zebradil makes iPython at least usable again (thanks!) but -
as already mentioned - decorates the prompt with & instead of colors.

@Choumingzhao
Copy link

I encounter this problem in my IPython 7.3.0. Have to stop extension to use IPython.

@GHPS
Copy link

GHPS commented Apr 2, 2019

When do you fix it~~~

Feel free to go ahead. Start with @Zebradil's patch and take a look
why the iPython prompt is reduced to a number of &s.

You would help a lot of people who are affected by this bug..

@acgtyrant
Copy link

What does "decorates the prompt with & instead of colors." look like? I use the patch and it looks like below:

2019-04-03-083801_739x255_scrot

There is not any &.

@GHPS
Copy link

GHPS commented Apr 3, 2019

Thank you for investigating further into this issue!

There is not any &.

In your case the "&" got replaced by "_" - interesting,
seems to be depended on the system you use.

This is how the prompt looks under Kubuntu 18.04:

iPython7-powerline

@PH111P
Copy link
Member

PH111P commented Apr 3, 2019

The & characters seem to be non-breaking space (\xa0); disabling them via the theme config replaces them with normal spaces. However, the colors still don't seem to change and everything has transparent background and #00005f as foreground color.

Screenshot_2019-04-03_21-04-52

I still think that the issue regarding the &'s is another issue, which is not related to the colors.

@GHPS
Copy link

GHPS commented Apr 3, 2019

In your case the "&" got replaced by "_" - interesting,
seems to be depended on the system you use.

It doesn't depend on the system but the version of
prompt-toolkit: I upgraded from 2.0.7 to 2.0.9
and all "&" are "_" now.

That is/was a new feature in 2.0.8:

  • Underline non breaking spaces instead of rendering as '&'.

@acgtyrant do you have 2.0.9 installed?

@PH111P
Copy link
Member

PH111P commented Apr 4, 2019

For the colors, it seems as if anything after the Token.Generic.Prompt is ignored:

return [(getattr(Token.Generic.Prompt.Powerline, name), contents)]

As far as I understand it, for every highlight group a new token type is created and the custom DynamicStyle defined in renderers/ipython/since_5.py is supposed to create the corresponding style. However, it seems that neither get_attrs_for_token nor get_token_to_attributes_dict get called; looking at prompt-toolkit/python-prompt-toolkit@c32f378 reveals that prompt_toolkit no longer uses get_attrs_for_token, but uses get_attrs_for_style_str instead.

@PH111P
Copy link
Member

PH111P commented Apr 4, 2019

It seems that I have a (very hacky) solution to the color problem: Record all used highlights in hl, convert them to prompt_toolkit-style format pairs and append these new pairs to the style rules already generated by implementing

    @property
    def style_rules(self):

in the class PowerlinePromptStyle(DynamicStyle):.

Screenshot_2019-04-04_18-41-31
As you can see I still need to clean up the code, but it seems to work.

@GHPS
Copy link

GHPS commented Apr 4, 2019

@PH111P - Great work, thanks for diving into the rabbit hole!

So both new problems (the missing colors and the "&"/"_") are caused by the
upgrade of prompt-toolkit to version 2?

@PH111P
Copy link
Member

PH111P commented Apr 4, 2019

So both new problems (the missing colors and the "&"/"_") are caused by the
upgrade of prompt-toolkit to version 2?

I think so, yes.

@GHPS
Copy link

GHPS commented Apr 4, 2019

Perhaps the guide "Upgrading to prompt_toolkit 2.0" is of any help
since it explains the changes needed:

https://python-prompt-toolkit.readthedocs.io/en/master/pages/upgrading.html#pygments-styles-and-token

@PH111P
Copy link
Member

PH111P commented Apr 5, 2019

An implementation of the color fix can be found here https://github.com/PH111P/powerline/blob/develop/powerline/renderers/ipython/since_7.py
The issue with the nbsp can be solved by disabling them in the config files (by setting "use_non_breaking_spaces": false).

If I happen to have some time, I might write a pull request.

@acgtyrant
Copy link

@GHPS I installed 2.0.8-1.

@GHPS
Copy link

GHPS commented Apr 5, 2019

An implementation of the color fix can be found here

Great - you fixed it. iPython and Powerline are usable again!
Thanks for taking the time and sorting it out...

Do you see a chance to resurrect the VI mode indicator
as well? It's currently missing...

@acgtyrant
Copy link

I add the color fix and the config, but there is still _ in my IPython, I do not know why.

2019-04-05-220405_165x64_scrot

@PH111P
Copy link
Member

PH111P commented Apr 5, 2019

I add the color fix and the config, but there is still _ in my IPython, I do not know why.

2019-04-05-220405_165x64_scrot

Ah sorry, indeed one cannot really use the configuration file for that (the mentioned flag only works at the global theme level; personally, I disabled nbsp's globally in the source but that shouldn't be the way to go); it seems like in order to fix the nbsp's, the ipython renderer needs to be changed, in particular adding something like the following to class IPythonPygmentsRenderer(IPythonRenderer): should fix this problem
(this time I actually tested that workaround, again sorry that the other thing didn't really work; see also https://github.com/PH111P/powerline/blob/develop/powerline/renderers/ipython/since_7.py)

    def __init__(self, **kwargs):
        super(IPythonPygmentsRenderer, self).__init__(**kwargs)
        self.character_translations[ord(' ')] = ' '

@PH111P
Copy link
Member

PH111P commented Apr 5, 2019

Do you see a chance to resurrect the VI mode indicator
as well? It's currently missing...

It seems as if there simply is no segment with that functionality. However, something along the following seems to work, feel free to convert this into a full-fledged segment (most of the code is shamelessly stolen from the actual ipython implementation: https://github.com/ipython/ipython/blob/4f901de17aff2132365fc3741fc5b4b8a9a98dc6/IPython/terminal/prompts.py#L16):

@requires_segment_info
def vi_mode(pl, segment_info):
    ipython = segment_info['ipython']._shell
    if (getattr(ipython.pt_app, 'editing_mode', None) == 'VI'
            and ipython.prompt_includes_vi_mode):
        return str(ipython.pt_app.app.vi_state.input_mode)[3:6]
    else:
        return None

Screenshot_2019-04-06_07-31-01

EDIT: While it does seem to show the current mode, it doesn't really seem to update though :/. I must admit that I don't really use the vi mode in ipython, so I cannot really test this.
EDIT 2: Fixed by updating the binding: https://github.com/PH111P/powerline/blob/448e73b41d61ab6617e86c1f7cfee3db19138700/powerline/bindings/ipython/since_7.py#L69

@PH111P PH111P mentioned this issue Apr 6, 2019
@GHPS
Copy link

GHPS commented Apr 6, 2019

@PH111P - Awesome! Great work!

@mprogram
Copy link

mprogram commented Jun 6, 2019

While acknowledging Philip's ( aka @PH111P ) great work, I would like to pose a question if anything could be done for the --simple-prompt option:

#!since_5.py

$ ipython
Python 2.7.15+ (default, Nov 27 2018, 23:36:35) 
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

 In [1] ▶                                                                                                                                                                                                          
Do you really want to exit ([y]/n)? y
#!since_7.py

$ ipython3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.6.0.dev -- An enhanced Interactive Python. Type '?' for help.

 In [1] ▶                                                                                                                                                                                                          
Do you really want to exit ([y]/n)? y
#!since_5.py

$ ipython --simple-prompt
Python 2.7.15+ (default, Nov 27 2018, 23:36:35) 
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/traitlets/config/application.py", line 831, in launch_instance
    app.start()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 355, in start
    self.shell.mainloop()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 495, in mainloop
    self.interact()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 478, in interact
    code = self.prompt_for_code()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 230, in prompt
    line = cast_unicode_py2(input(prompt_text))
  File "/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.py", line 220, in input
    return builtin_mod.raw_input(prompt)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 0: ordinal not in range(128)

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True
#!since_7.py

$ ipython3 --simple-prompt
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.6.0.dev -- An enhanced Interactive Python. Type '?' for help.

 In [1] ▶

@alabamagan
Copy link

The PR seems to have left unattended for some time. Is there any plan to update this?

@PH111P
Copy link
Member

PH111P commented Aug 22, 2019

As far as I know, everything (except --simple-prompt) seems to work, so I'm not totally sure what you are referring to, @teracamo. (Indeed, the PR did not get merged yet, but this seems to be related to #2012; also strictly speaking the PR is still lacking tests, but as I said, it should be usable already)

@alabamagan
Copy link

Oh I am just referring to if there's any plan that this PR would be merged, since the current version don't work on ipython >= 7.0.
I haven't tried the PR myself yet, so I can't say anything about the --simple-prompt option but I will do it if there ain't any plan to merge it.

@PH111P PH111P self-assigned this Sep 23, 2019
PH111P added a commit that referenced this issue Oct 7, 2019
* ipython fix

* ipython fix

* ipython fix

* fix ipython startup

* better fix for nbsp

* ipython7: fix attributes

* Change ipythen tests to use new binding

* ipython test: use proper config
@vegerot
Copy link
Contributor

vegerot commented Nov 19, 2019

@alabamagan how is #2048 ?

@dylon
Copy link
Author

dylon commented Nov 21, 2019

Until the changes are released, checkout the develop branch to get them. It may be less stable than master, but it beats not being able to use powerline prompts at all:

pip install --user 'git+https://github.com/powerline/powerline.git@develop#powerline'

Then, in your ipython config, change since_5 to since_7, like this:

from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts

@vegerot
Copy link
Contributor

vegerot commented Nov 21, 2019

How long until they're released?

@CoelacanthusHex
Copy link

Maybe a new release is needed.
Last release is 2 years ago.

@otakutyrant
Copy link

Thanks for a new release. But I still encountered this bug after I upgraded powerline to 2.8-1. I do not know why.



 19:05:12  ~ 
$ ipython                                                                                            otakutyrant  PC
Python 3.8.2 (default, Apr  8 2020, 14:31:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.

Traceback (most recent call last):
  File "/usr/bin/ipython", line 5, in <module>
    start_ipython()
  File "/usr/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
    self.shell.mainloop()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 559, in mainloop
    self.interact()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 542, in interact
    code = self.prompt_for_code()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 468, in prompt_for_code
    text = self.pt_app.prompt(
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
    return self.app.run(set_exception_handler=set_exception_handler)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run
    return loop.run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async
    return await _run_async2()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2
    result = await _run_async()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 686, in _run_async
    self._redraw()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw
    self.context.run(run_in_context)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context
    self.renderer.render(self, self.layout)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 581, in render
    self.style.invalidation_hash() != self._last_style_hash
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in invalidation_hash
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in <genexpr>
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash
    return super(PowerlinePromptStyle, self).invalidation_hash() + 1
TypeError: can only concatenate tuple (not "int") to tuple

If you suspect this is an IPython 7.14.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True


 19:05:15  ✘  ~ 
$ pacman -Qi powerline                                                                               otakutyrant  PC
Name            : powerline
Version         : 2.8-1
Description     : Statusline plugin for vim, and provides statuslines and prompts for several other applications,
                  including zsh, bash, tmux, IPython, Awesome, i3 and Qtile
Architecture    : x86_64
URL             : https://github.com/powerline/powerline
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : python-powerline
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : powerline2  python-powerline<=2.3-1
Replaces        : python-powerline<=2.3-1
Installed Size  : 28.39 KiB
Packager        : Jiachen YANG <farseerfc@archlinux.org>
Build Date      : Mon 18 May 2020 01:55:40 PM CST
Install Date    : Tue 19 May 2020 06:55:56 PM CST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature


 19:09:25  ~ 
$                                                                                                    otakutyrant  PC

/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_7.py exists already.

@CoelacanthusHex
Copy link

Thanks for a new release. But I still encountered this bug after I upgraded powerline to 2.8-1. I do not know why.



 19:05:12  ~ 
$ ipython                                                                                            otakutyrant  PC
Python 3.8.2 (default, Apr  8 2020, 14:31:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.

Traceback (most recent call last):
  File "/usr/bin/ipython", line 5, in <module>
    start_ipython()
  File "/usr/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
    self.shell.mainloop()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 559, in mainloop
    self.interact()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 542, in interact
    code = self.prompt_for_code()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 468, in prompt_for_code
    text = self.pt_app.prompt(
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
    return self.app.run(set_exception_handler=set_exception_handler)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run
    return loop.run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async
    return await _run_async2()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2
    result = await _run_async()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 686, in _run_async
    self._redraw()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw
    self.context.run(run_in_context)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context
    self.renderer.render(self, self.layout)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 581, in render
    self.style.invalidation_hash() != self._last_style_hash
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in invalidation_hash
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in <genexpr>
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash
    return super(PowerlinePromptStyle, self).invalidation_hash() + 1
TypeError: can only concatenate tuple (not "int") to tuple

If you suspect this is an IPython 7.14.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True


 19:05:15  ✘  ~ 
$ pacman -Qi powerline                                                                               otakutyrant  PC
Name            : powerline
Version         : 2.8-1
Description     : Statusline plugin for vim, and provides statuslines and prompts for several other applications,
                  including zsh, bash, tmux, IPython, Awesome, i3 and Qtile
Architecture    : x86_64
URL             : https://github.com/powerline/powerline
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : python-powerline
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : powerline2  python-powerline<=2.3-1
Replaces        : python-powerline<=2.3-1
Installed Size  : 28.39 KiB
Packager        : Jiachen YANG <farseerfc@archlinux.org>
Build Date      : Mon 18 May 2020 01:55:40 PM CST
Install Date    : Tue 19 May 2020 06:55:56 PM CST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature


 19:09:25  ~ 
$                                                                                                    otakutyrant  PC

/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_7.py exists already.

You should add

from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts

to config. https://github.com/powerline/powerline/blob/develop/docs/source/usage/other.rst
The doc is not updated.

@otakutyrant
Copy link

I added it into the config and it works now. Thank you!

@PH111P
Copy link
Member

PH111P commented May 20, 2020

Thanks for a new release. But I still encountered this bug after I upgraded powerline to 2.8-1. I do not know why.



 19:05:12  ~ 
$ ipython                                                                                            otakutyrant  PC
Python 3.8.2 (default, Apr  8 2020, 14:31:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.

Traceback (most recent call last):
  File "/usr/bin/ipython", line 5, in <module>
    start_ipython()
  File "/usr/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
    self.shell.mainloop()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 559, in mainloop
    self.interact()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 542, in interact
    code = self.prompt_for_code()
  File "/usr/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 468, in prompt_for_code
    text = self.pt_app.prompt(
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
    return self.app.run(set_exception_handler=set_exception_handler)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 811, in run
    return loop.run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 778, in run_async
    return await _run_async2()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2
    result = await _run_async()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 686, in _run_async
    self._redraw()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw
    self.context.run(run_in_context)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context
    self.renderer.render(self, self.layout)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py", line 581, in render
    self.style.invalidation_hash() != self._last_style_hash
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in invalidation_hash
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/style.py", line 398, in <genexpr>
    return tuple(s.invalidation_hash() for s in self.styles)
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/prompt_toolkit/styles/base.py", line 177, in invalidation_hash
    return (self.get_style() or self._dummy).invalidation_hash()
  File "/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_5.py", line 79, in invalidation_hash
    return super(PowerlinePromptStyle, self).invalidation_hash() + 1
TypeError: can only concatenate tuple (not "int") to tuple

If you suspect this is an IPython 7.14.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True


 19:05:15  ✘  ~ 
$ pacman -Qi powerline                                                                               otakutyrant  PC
Name            : powerline
Version         : 2.8-1
Description     : Statusline plugin for vim, and provides statuslines and prompts for several other applications,
                  including zsh, bash, tmux, IPython, Awesome, i3 and Qtile
Architecture    : x86_64
URL             : https://github.com/powerline/powerline
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : python-powerline
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : powerline2  python-powerline<=2.3-1
Replaces        : python-powerline<=2.3-1
Installed Size  : 28.39 KiB
Packager        : Jiachen YANG <farseerfc@archlinux.org>
Build Date      : Mon 18 May 2020 01:55:40 PM CST
Install Date    : Tue 19 May 2020 06:55:56 PM CST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature


 19:09:25  ~ 
$                                                                                                    otakutyrant  PC

/usr/lib/python3.8/site-packages/powerline/renderers/ipython/since_7.py exists already.

You should add

from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts

to config. https://github.com/powerline/powerline/blob/develop/docs/source/usage/other.rst
The doc is not updated.

Indeed, the docs are quite old (the last build is from ~1.5 years ago). However, the automatic builds somehow don't work and I lack the permissions to check/change anything about the configs, sorry.

@GHPS
Copy link

GHPS commented Jun 4, 2020

@PH111P Please push the new release to PyPI as well. It still has only version 2.7...

@PH111P
Copy link
Member

PH111P commented Jun 4, 2020

Sadly, I don't think that I have the access right to do so.
In the meantime, you may try pip install git+https://github.com/powerline/powerline.git@develop.

@broander
Copy link

It would be great if someone would merge this into the master branch so we could get it into PyPI and also into the powerline-status conda-forge package.

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

Successfully merging a pull request may close this issue.