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.

classification
Title: textwrap does not handle single quotes with hyphens properly
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gward Nosy List: gward
Priority: normal Keywords:

Created on 2004-06-03 01:24 by gward, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg21003 - (view) Author: Greg Ward (gward) (Python committer) Date: 2004-06-03 01:24
This problem was reported as an Optik bug (#813077),
but it's really a problem in textwrap.  (Darn, textwrap
is harder to tweak.)  In a nutshell,
TextWrapper._split() splits this string wrong:
  "the 'wibble-wobble' widget"
It should split into
  ['the', ' ', "'wibble-", "wobble'", ' ', 'widget']
but it actually splits into 
  ['the', ' ', "'", 'wibble-', "wobble'", ' ', 'widget']

Looks like that damn regex needs a bit more tweaking. 
SIgh.
msg21004 - (view) Author: Greg Ward (gward) (Python committer) Date: 2004-06-03 02:00
Logged In: YES 
user_id=14422

Turns out the fix was fairly easy: there was already a
special case in wordsep_re so that Optik and Docutils could
wrap long options like "--foo-bar" correctly.  Generalizing
that special case to any punctuation ([^\s\w]) fixes this bug.

Fixed on release23-maint branch:
  Lib/textwrap.py rev 1.32.8.3
  Lib/test/test_textwrap.py rev 1.22.8.3

Merged onto trunk:
  Lib/textwrap.py rev 1.35
  Lib/test/test_textwrap.py rev 1.26
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40337
2004-06-03 01:24:16gwardcreate