This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年09月13日 15:29 by atagar1, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg143977 - (view) | Author: Damian (atagar1) | Date: 2011年09月13日 15:29 | |
Hi, when using terminal coloring codes (for instance '\x1b[32mhello world\x1b[0m' for a green 'hello world') the raw_input function and readline module behave well except under a very specific use case... ======================================== import readline # provides history via up/down prompt = '\x1b[32m>>> \x1b[0m' # green '>>> ' prompt while True: raw_input(prompt) ======================================== This provides a green prompt and up/down cycles through prior input. This works well as long as the input is shorter than the prompt string length (in this case 13 characters). However, if the input is longer than the prompt then up/down thinks that the first thirteen rendered characters now belong to the prompt. For instance... atagar@fenrir:~/Desktop/arm$ python tmp.py >>> http://docs.python.org/library/readline Press up, then down to get back to a blank prompt. You'll have... >>> http://do This is probably due to a len() check on the raw_input argument... >>> len('>>> http://do') 13 >>> len('\x1b[32m>>> \x1b[0m') 13 I'm at a bit of a loss for investigating this further - help would be appreciated! -Damian |
|||
| msg144150 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年09月16日 19:03 | |
From your version choice, you apparently are using 2.6, which is in security-fix only mode. Please test with the latest 2.7 and/or 3.2. |
|||
| msg144227 - (view) | Author: Damian (atagar) | Date: 2011年09月18日 04:34 | |
Retested with Python 3.1.1 and this issue doesn't manifest. This can be resolved - sorry about the noise. :) |
|||
| msg144245 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年09月18日 17:10 | |
Since 2.7 was released after 3.1, I will assumed any bugfix was applied there also until someone determines otherwise. Thanks for checking. |
|||
| msg219101 - (view) | Author: Damian (atagar) | Date: 2014年05月25日 19:34 | |
Just a quick comment that I ran into this again, but turns out that it's not an issue with python. Rather, this is a quirk with how readline works... https://stackoverflow.com/questions/9468435/look-how-to-fix-column-calculation-in-python-readline-if-use-color-prompt Color prompts need to be wrapped by RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE. |
|||
| msg219106 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年05月25日 21:45 | |
Thanks for the followup. This should be useful info for anyone who finds this issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:21 | admin | set | github: 57181 |
| 2014年05月25日 21:45:07 | terry.reedy | set | messages: + msg219106 |
| 2014年05月25日 19:34:41 | atagar | set | messages: + msg219101 |
| 2011年09月18日 17:10:26 | terry.reedy | set | status: open -> closed resolution: out of date messages: + msg144245 |
| 2011年09月18日 04:34:48 | atagar | set | nosy:
+ atagar messages: + msg144227 |
| 2011年09月16日 19:03:24 | terry.reedy | set | versions:
+ Python 2.7, - Python 2.6 nosy: + terry.reedy messages: + msg144150 stage: test needed |
| 2011年09月13日 15:29:32 | atagar1 | create | |