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

OS X Lion Terminal.app line wrap problem #915

Closed
radeksz opened this issue Oct 21, 2011 · 12 comments
Closed

OS X Lion Terminal.app line wrap problem #915

radeksz opened this issue Oct 21, 2011 · 12 comments
Milestone

Comments

@radeksz
Copy link

radeksz commented Oct 21, 2011

I have a problem with deadline on Mac OS X Lion, ipython 0.11, python 2.7.2. When wrapping the input line the line prompt isn't taken into account properly. It gets all messy when I press delete in the long line.

The amount of "error" per line is dependent on the length of the prompt. If I make the prompt one character longer, the first line is wrapped one character "later".

Example:

ipython --colors=NoColor
Python 2.7.2 (default, Aug 16 2011, 18:48:22) 
Type "copyright", "credits" or "license" for more information.

IPython 0.11 -- 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]: 012345678901234567890123456789012345678901234567890123456789012345678901
2345678
90123456789012345678901234567890123456789012345678901234567890123456789012345678
90123456789012345678901234567890123456789012345678901234567890123456789012345678
90123456789012345678901234567890123456789012345678901234567890123456789012345678
90123456789012345678901234567890123456789012345678901234567890123456789012345678
90123456789012345678901234567890123456789012345678901234567890123456789012345678

I have readline installed:

[Radek ~]$ fink list|grep readline
 i  readline5   5.0-1006    Comfortable terminal input library
 i  readline5-shlibs    5.0-1006    Comfortable terminal input library
@bfroehle
Copy link
Contributor

I don't have this issue using the homebrew version of python 2.7.2 (and readline 6.2.1).

@minrk
Copy link
Member

minrk commented Oct 21, 2011

What Python does have this problem? If homebrew Python doesn't have it for you, and System Python doesn't appear to have it for me.

And how are you causing the problem - is it resizing the window, or just typing out a long line that it waits too long to wrap?

@radeksz
Copy link
Author

radeksz commented Oct 22, 2011

Fink Python 2.7.2 (version 1:2.7.2-4) and Lion system python (Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)) do not have this problem, only ipython (fink installation ipython-py27, 0.11-3).

It's typing a long line that causes this "late" wrap, no resizing of the window needed. Colors of the prompt have no influence on the wrap.

@minrk
Copy link
Member

minrk commented Oct 22, 2011

Interesting. Can you run a standard dist or git master of IPython with your System or Fink Pythons? You can use python ipython.py from the source dir to launch IPython without installing it.

Another thing you might test is launching without readline:

$> ipython --InteractiveShell.readline_use=False

I don't think IPython configures anything about line wrapping, but I'm definitely not sure about that.

@radeksz
Copy link
Author

radeksz commented Oct 23, 2011

I did run ipython from git (0.12dev) and the problem persists (as of 23 October 2011) when ipython is run with fink python 2.7.2.

When I manually disable readline in 0.12dev with --InteractiveShell.readline_use=False, ipython crashes:

[Radek ipython]$ /sw/bin/python ipython.py --InteractiveShell.readline_use=False # fink python
ipython/IPython/frontend/terminal/interactiveshell.pyc in interact(self=<IPython.frontend.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=False)


    257         more = False
--> 258         hlen_before_cell = self.readline.get_current_history_length()
    259 

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

After "fixing" the crash (changing the offending line to hlen_before_cell = 0) the input lines keep being wrapped incorrectly.

Problem disappears for system (Lion) python 2.7.1, but with some readline warnings.

[Radek ipython]$ /usr/bin/python ipython.py # Lion python
IPython/utils/rlineimpl.py:96: RuntimeWarning: Leopard libedit detected - readli
ne will not be well behaved including some crashes on tab completion, and incorr
ect history navigation. It is highly recommended that you install readline, whic
h is easy_installable with: 'easy_install readline'
  RuntimeWarning)
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
Type "copyright", "credits" or "license" for more information.

IPython 0.12.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]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

@minrk
Copy link
Member

minrk commented Oct 23, 2011

Sorry, that readline crash is due to a small omission in a recent PR, fix is forthcoming.

Frankly, it sounds like a bug in Fink Python. What happens if you just do:

raw_input('long prompt > ')

from Fink Python, and then enter more than a line?

@radeksz
Copy link
Author

radeksz commented Oct 23, 2011

The raw_input function works in (fink) python correctly.

[Radek ipython]$ /sw/bin/python ipython.py # fink python, 23 Oct 2011 ipython 0.12dev
 Python 2.7.2 (default, Aug 16 2011, 18:48:22) 
Type "copyright", "credits" or "license" for more information.

IPython 0.12.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]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

In [2]: raw_input('long prompt > ')
long prompt > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

@radeksz
Copy link
Author

radeksz commented Oct 24, 2011

I think I identified the problem, it's the \n in the prompt that causes incorrect line wrap. It appears to have nothing with ipython, as it surfaces with raw_input:

[Radek ipython]$ /sw/bin/python
Python 2.7.2 (default, Aug 16 2011, 18:48:22) 
[GCC 4.2.1 Compatible Apple Clang 2.1 (tags/Apple/clang-163.7.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> raw_input('prompt>')
prompt>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

>>> raw_input('\nprompt>')

prompt>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

My temporary fix includes changing ipython_config.py:

c.TerminalInteractiveShell.separate_in = '' # was '\n'

The problem doesn't occur on system (Lion) python. I guess I should file a bug report for readline (fink version 5.0-1006)?

@radeksz
Copy link
Author

radeksz commented Oct 25, 2011

Indeed it is the readline library that causes problems.

http://sourceforge.net/mailarchive/message.php?msg_id=28278097

@radeksz radeksz closed this as completed Oct 25, 2011
@minrk
Copy link
Member

minrk commented Oct 25, 2011

Thanks for narrowing it down! Perhaps you can install the python-readline package, which links against current gnu readline:

easy_install readline

If you do that --user, or on your PYTHONPATH, it should be used instead of the default readline.

@stefan-pdx
Copy link

I'm still experiencing this issue.

Homebrew has picked this up in Homebrew/legacy-homebrew#30751 where another user posted a video that show similar behavior with readline in R.

As of 7/2014, the GNU Readline project are looking into it, but I don't think there have been any updates. Perhaps this is a regression on their end.

@vsbuffalo
Copy link

I'm this other user, can we get an official readline rollback in Homebrew? This affects more than Python — everything uses readline.

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

No branches or pull requests

5 participants