[Python-checkins] python/dist/src/Lib textwrap.py,1.36,1.37

gward at users.sourceforge.net gward at users.sourceforge.net
Sat Mar 5 03:53:19 CET 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12862/Lib

Modified Files:
	textwrap.py 
Log Message:
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
eg. "2004-03-04" is not broken across lines.  (Merged from 2.4 branch.)


Index: textwrap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- textwrap.py	3 Jan 2005 07:14:12 -0000	1.36
+++ textwrap.py	5 Mar 2005 02:53:16 -0000	1.37
@@ -78,9 +78,10 @@
     # 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)



More information about the Python-checkins mailing list