[ python-Bugs-965425 ] textwrap does not handle single quotes with hyphens properly

SourceForge.net noreply at sourceforge.net
Wed Jun 2 22:00:09 EDT 2004


Bugs item #965425, was opened at 2004-06-02 21:24
Message generated for change (Comment added) made by gward
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=965425&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Greg Ward (gward)
Assigned to: Greg Ward (gward)
Summary: textwrap does not handle single quotes with hyphens properly

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Greg Ward (gward)
Date: 2004-06-02 22:00

Message:
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


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=965425&group_id=5470



More information about the Python-bugs-list mailing list