[issue20359] Having escape sequences (like color codes) in the sys.ps1 messes up readline's input line calculations

Steve report at bugs.python.org
Thu Jan 23 11:10:17 CET 2014


Steve added the comment:

Although surrounding the escapes with \x01 and \x02 worked to correctly remove the message while doing a reverse-i-search (thus preserving the original line), the input line measurement still appears to be incorrect as demonstated with the following actions:

[steve at 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 = '\x01\033[32m>>> \033[0m\x02'
>>> # on the next line, press the up arrow to get this line and then backspace, over the entire prompt
... 
#<-- backspaced up until here
... 


...again, not a big deal, just annoying when deleting word with a repeated 'alt+backspace' or ctrl+w

----------
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20359>
_______________________________________


More information about the Python-bugs-list mailing list