New submission from Steve: If you change the sys.ps1 to have some color, you end up messing up readline's input line calculations and the characters in the line you are typing might not get displayed properly. This behaviour is easier to demonstrate/reporduce than explain ...:
On a python promt with readline enabled (for instance, on any linux box): [steve@localhost ~]$ python Python 2.7.5 (default, Nov 12 2013, 16:18:42) [GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.ps1 = '\033[31m>>> \033[0m' >>> # doing a reverse-i-search (Ctrl+r) on the next line will mess up the >>> prompt display ... >>> h)`sys': sys.ps1 = '\033[31m>>> \033[0m' (...press Ctrl-L to clear...) (reverse-i-search)`': (press enter) >>> arch)`': I did some (amateur) investigation and the root cause might be similar to what's reported at: http://trac.haskell.org/haskeline/ticket/78 https://groups.google.com/forum/#!topic/gnu.bash.bug/5P0gWzzLVOU FWIW, I bumped into this issue while customizing my .pythonrc[1] and although it might be a silly small annoyance, it would be really nice if this bug could be fixed. [1] https://gist.github.com/lonetwin/5902720 ---------- components: Library (Lib) messages: 208890 nosy: lonetwin priority: normal severity: normal status: open title: Having escape sequences (like color codes) in the sys.ps1 messes up readline's input line calculations type: behavior versions: Python 2.7, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20359> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com