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.

Author chris.jerdonek
Recipients chris.jerdonek
Date 2012-07-29.21:11:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
While working on issue 1859, I noticed that textwrap.wrap()'s tab expansion does not seem to behave sensibly.

In particular, the documentation says, "If expand_tabs is true, then all tab characters in text will be expanded to zero or more spaces, *depending on the current column* and the given tab size."

The problem is that tab expansion is done as the first stage (and in particular, before wrapping), which means that "the current column" is no longer current after wrapping.  This leads to results like--

from textwrap import wrap

text = ("a\tb "

lines = wrap(text, width=5, tabsize=4)
for line in lines:

'a   b'
'a b'

One would expect tab expansion to occur after (or while) wrapping, so that tab stops line up in the wrapped output.
Date User Action Args
2012-07-29 21:11:57chris.jerdoneksetrecipients: + chris.jerdonek
2012-07-29 21:11:57chris.jerdoneksetmessageid: <>
2012-07-29 21:11:56chris.jerdoneklinkissue15492 messages
2012-07-29 21:11:56chris.jerdonekcreate