-
Notifications
You must be signed in to change notification settings - Fork 990
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
Comments
|
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:
|
So In prompt_toolkit<2.0.0 |
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. |
Would it be worth creating a |
Could this be done? This is preventing me from using Powerline. |
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. |
The |
I can confirm that powerline is broken for the current versions of iPython (7.4 in my case). |
I encounter this problem in my IPython 7.3.0. Have to stop extension to use IPython. |
Feel free to go ahead. Start with @Zebradil's patch and take a look You would help a lot of people who are affected by this bug.. |
I still think that the issue regarding the |
It doesn't depend on the system but the version of That is/was a new feature in 2.0.8:
@acgtyrant do you have 2.0.9 installed? |
For the colors, it seems as if anything after the
As far as I understand it, for every highlight group a new token type is created and the custom |
@PH111P - Great work, thanks for diving into the rabbit hole! So both new problems (the missing colors and the "&"/"_") are caused by the |
I think so, yes. |
Perhaps the guide "Upgrading to prompt_toolkit 2.0" is of any help |
An implementation of the color fix can be found here https://github.com/PH111P/powerline/blob/develop/powerline/renderers/ipython/since_7.py If I happen to have some time, I might write a pull request. |
@GHPS I installed 2.0.8-1. |
Great - you fixed it. iPython and Powerline are usable again! Do you see a chance to resurrect the VI mode indicator |
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 def __init__(self, **kwargs):
super(IPythonPygmentsRenderer, self).__init__(**kwargs)
self.character_translations[ord(' ')] = ' ' |
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 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. |
@PH111P - Awesome! Great work! |
While acknowledging Philip's ( aka @PH111P ) great work, I would like to pose a question if anything could be done for the #!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] ▶ |
The PR seems to have left unattended for some time. Is there any plan to update this? |
As far as I know, everything (except |
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. |
@alabamagan how is #2048 ? |
Until the changes are released, checkout the pip install --user 'git+https://github.com/powerline/powerline.git@develop#powerline' Then, in your ipython config, change from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts |
How long until they're released? |
Maybe a new release is needed. |
Thanks for a new release. But I still encountered this bug after I upgraded powerline to 2.8-1. I do not know why.
|
You should add
to config. https://github.com/powerline/powerline/blob/develop/docs/source/usage/other.rst |
I added it into the config and it works now. Thank you! |
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. |
@PH111P Please push the new release to PyPI as well. It still has only version 2.7... |
Sadly, I don't think that I have the access right to do so. |
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. |
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:
The text was updated successfully, but these errors were encountered: