New submission from Krzysztof Słychań:

Strings containing ANSI escape sequences are not justified if the length 
including escape sequences exceeds the field width.

Testcase:
Let's make a string with escape sequences - bold, for example:
>>> string = '\033[01m' + 'bold' + '\033[0m'

String length will be larger than the length of a displayed string
(should be 4, is 13). Looks like '\03' is counted as escape sequence,
but '3[01m' and '3[0m' are not, and count into the string length.
>>> len(string)
13

Try to print justified string - should be centered between '|' signs
>>> print('|' + string.center(10) + '|')
|bold|
Does not work at all...

If field length is larger than len(string), justification works
>>> print('|' + string.center(30) + '|')
|        bold         |

----------
components: Interpreter Core
messages: 246351
nosy: Krzysztof Słychań
priority: normal
severity: normal
status: open
title: ANSI escape sequences breaking string justification
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24574>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to