summaryrefslogtreecommitdiffstats
path: root/Lib/textwrap.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2005-03-05 02:53:17 (GMT)
committerGreg Ward <gward@python.net>2005-03-05 02:53:17 (GMT)
commit40407943b72dfcbac498f92a9c8b774ee2ea7ee2 (patch)
tree31611f78855e372e54fea69fd004540a08fc8b93 /Lib/textwrap.py
parent00a73e7715eb9bba3203aea6caa326f3f54a0d20 (diff)
downloadcpython-40407943b72dfcbac498f92a9c8b774ee2ea7ee2.zip
cpython-40407943b72dfcbac498f92a9c8b774ee2ea7ee2.tar.gz
cpython-40407943b72dfcbac498f92a9c8b774ee2ea7ee2.tar.bz2
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
eg. "2004-03-04" is not broken across lines. (Merged from 2.4 branch.)
Diffstat (limited to 'Lib/textwrap.py')
-rw-r--r--Lib/textwrap.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/textwrap.py b/Lib/textwrap.py
index 8e3d8cf..4576ef2 100644
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -78,9 +78,10 @@ class TextWrapper:
# splits into
# Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
# (after stripping out empty strings).
- wordsep_re = re.compile(r'(\s+|' # any whitespace
- r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words
- r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
+ wordsep_re = re.compile(
+ r'(\s+|' # any whitespace
+ r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|' # hyphenated words
+ r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
# XXX this is not locale- or charset-aware -- string.lowercase
# is US-ASCII only (and therefore English-only)