Issue 13152: textwrap: support custom tabsize (original) (raw)

Created on 2011-10-11 13:05 by john.feuerstein, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
textwrap_tabsize.diff john.feuerstein,2011-10-11 13:04 review
textwrap_tabsize_v2.diff john.feuerstein,2011-11-07 13:58 review
Messages (8)
msg145341 - (view) Author: John Feuerstein (john.feuerstein) * Date: 2011-10-11 13:04
The textwrap module calls .expandtabs() to expand tabs to spaces. This patch adds support for a custom tabsize, so that .expandtabs(tabsize) is called instead. Includes test case.
msg145572 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-10-14 23:40
I am a bit surprised this was not part of the original design. 'Tabsize' make 'expand_tabs' redundant and tabsize==0 could be interpreted as expand_tabs==False. On the other hand, the meaning of 'expand_tabs' could be expanded to include the tabsize. I am almost tempted to suggest making expand_tabs > 1 be interpreted as tabsize and make expand_tabs==True(1, the current default) be interpreted as expand_tabs==8 (the new default) for back_compatibility. Patch as is has new tests and looks good on first reading.
msg145878 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-10-18 23:53
+1
msg146764 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-11-01 09:53
Two comments: * The new parameter to __init__ should be added at the end of the parameter list. * A documentation update would be nice.
msg147221 - (view) Author: John Feuerstein (john.feuerstein) * Date: 2011-11-07 13:58
textwrap_tabsize_v2.diff: * Moved the tabsize parameter to the end of the parameter list * Added documentation update * Made the test case more obvious
msg159689 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-04-30 11:22
The code LGTM, the documentation lacks `versionchanged` tag though. Would you mind adding it?
msg161110 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-19 11:49
New changeset d38e821c1b80 by Hynek Schlawack in branch 'default': #13152: Allow to specify a custom tabsize for expanding tabs in textwrap http://hg.python.org/cpython/rev/d38e821c1b80
msg161111 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-05-19 11:50
I've added it myself and committed your code – thank you for your contribution John!
History
Date User Action Args
2022-04-11 14:57:22 admin set github: 57361
2012-05-19 11:50:52 hynek set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2012-05-19 11:49:06 python-dev set nosy: + python-devmessages: +
2012-04-30 11:22:08 hynek set nosy: + hynekmessages: +
2011-11-07 13:58:37 john.feuerstein set files: + textwrap_tabsize_v2.diffmessages: +
2011-11-01 09:53:58 georg.brandl set messages: +
2011-10-18 23:53:58 rhettinger set nosy: + rhettingermessages: +
2011-10-14 23:40:11 terry.reedy set nosy: + terry.reedymessages: +
2011-10-11 13:13:54 ezio.melotti set keywords: + needs reviewnosy: + georg.brandlstage: patch review
2011-10-11 13:05:00 john.feuerstein create