[New-bugs-announce] [issue1146] TextWrap vs words 1-character shorter than the width

sam report at bugs.python.org
Tue Sep 11 15:37:37 CEST 2007


New submission from sam:

>>> from textwrap import wrap
>>> wrap("foobarbaz reallylongwordgoeshere", width = 10)
['foobarbaz r', 'eallylongw', 'ordgoesher', 'e']
>>> print [len(s) for s in _]
[11, 10, 10, 1]

This only seems to happen when the first word on the line is exactly one
character shorter than the width, and the next word is too long to fit,
so it is broken:

>>> wrap("foo bar reallylongwordgoeshere", width = 7)
['foo bar', 'reallyl', 'ongword', 'goesher', 'e']
>>> wrap("foobarbaz really longwordgoeshere", width = 10)
['foobarbaz', 'really lon', 'gwordgoesh', 'ere']
>>> wrap("foobarbaz reallylongwordgoeshere", width = 10,
break_long_words = False)
['foobarbaz', 'reallylongwordgoeshere']

This is on Python 2.5, on Windows XP SP2.

----------
messages: 55822
nosy: sam
severity: normal
status: open
title: TextWrap vs words 1-character shorter than the width
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1146>
__________________________________


More information about the New-bugs-announce mailing list