Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textwrap does not handle single quotes with hyphens properly #40337

Closed
gward mannequin opened this issue Jun 3, 2004 · 2 comments
Closed

textwrap does not handle single quotes with hyphens properly #40337

gward mannequin opened this issue Jun 3, 2004 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@gward
Copy link
Mannequin

gward mannequin commented Jun 3, 2004

BPO 965425

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2004-06-03.02:00:08.000>
created_at = <Date 2004-06-03.01:24:16.000>
labels = ['library']
title = 'textwrap does not handle single quotes with hyphens properly'
updated_at = <Date 2004-06-03.02:00:08.000>
user = 'https://bugs.python.org/gward'

bugs.python.org fields:

activity = <Date 2004-06-03.02:00:08.000>
actor = 'gward'
assignee = 'gward'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2004-06-03.01:24:16.000>
creator = 'gward'
dependencies = []
files = []
hgrepos = []
issue_num = 965425
keywords = []
message_count = 2.0
messages = ['21003', '21004']
nosy_count = 1.0
nosy_names = ['gward']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue965425'
versions = ['Python 2.3']

@gward
Copy link
Mannequin Author

gward mannequin commented Jun 3, 2004

This problem was reported as an Optik bug (bpo-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.

@gward gward mannequin closed this as completed Jun 3, 2004
@gward gward mannequin self-assigned this Jun 3, 2004
@gward gward mannequin added the stdlib Python modules in the Lib dir label Jun 3, 2004
@gward gward mannequin closed this as completed Jun 3, 2004
@gward gward mannequin self-assigned this Jun 3, 2004
@gward gward mannequin added the stdlib Python modules in the Lib dir label Jun 3, 2004
@gward
Copy link
Mannequin Author

gward mannequin commented Jun 3, 2004

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

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

0 participants