Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7c59bc6f
Commit
7c59bc6f
authored
Dec 13, 2008
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
parent
d9c03e0d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
1 deletion
+12
-1
Lib/test/test_textwrap.py
Lib/test/test_textwrap.py
+8
-0
Lib/textwrap.py
Lib/textwrap.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_textwrap.py
View file @
7c59bc6f
...
@@ -365,6 +365,14 @@ What a mess!
...
@@ -365,6 +365,14 @@ What a mess!
self
.
assertRaises
(
ValueError
,
wrap
,
text
,
0
)
self
.
assertRaises
(
ValueError
,
wrap
,
text
,
0
)
self
.
assertRaises
(
ValueError
,
wrap
,
text
,
-
1
)
self
.
assertRaises
(
ValueError
,
wrap
,
text
,
-
1
)
def
test_no_split_at_umlaut
(
self
):
text
=
"Die Empf
\
xe4
nger-Auswahl"
self
.
check_wrap
(
text
,
13
,
[
"Die"
,
"Empf
\
xe4
nger-"
,
"Auswahl"
])
def
test_umlaut_followed_by_dash
(
self
):
text
=
"aa
\
xe4
\
xe4
-
\
xe4
\
xe4
"
self
.
check_wrap
(
text
,
7
,
[
"aa
\
xe4
\
xe4
-"
,
"
\
xe4
\
xe4
"
])
class
LongWordTestCase
(
BaseTestCase
):
class
LongWordTestCase
(
BaseTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
Lib/textwrap.py
View file @
7c59bc6f
...
@@ -76,7 +76,7 @@ class TextWrapper:
...
@@ -76,7 +76,7 @@ class TextWrapper:
# (after stripping out empty strings).
# (after stripping out empty strings).
wordsep_re
=
re
.
compile
(
wordsep_re
=
re
.
compile
(
r'(\
s+|
' # any whitespace
r'(\
s+|
' # any whitespace
r'
[
^
\
s
\
w
]
*
\
w
+
[
a
-
zA
-
Z
]
-
(
?
=
\
w
+
[
a
-
zA
-
Z
])
|
' # hyphenated words
r'
[
^
\
s
\
w
]
*
\
w
+
[
^
0
-
9
\
W
]
-
(
?
=
\
w
+
[
^
0
-
9
\
W
])
|
' # hyphenated words
r'
(
?
<=
[
\
w
\
!
\
"
\
'
\
&
\
.
\
,
\
?])-{2,}(?=
\
w))
'
) # em-dash
r'
(
?
<=
[
\
w
\
!
\
"
\
'
\
&
\
.
\
,
\
?])-{2,}(?=
\
w))
'
) # em-dash
# This less funky little regex just split on recognized spaces. E.g.
# This less funky little regex just split on recognized spaces. E.g.
...
...
Misc/NEWS
View file @
7c59bc6f
...
@@ -45,6 +45,9 @@ Core and Builtins
...
@@ -45,6 +45,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #4163: textwrap module: allow word splitting on a hyphen preceded by
a non-ASCII letter.
- Issue #4616: TarFile.utime(): Restore directory times on Windows.
- Issue #4616: TarFile.utime(): Restore directory times on Windows.
- Issue #4021: tokenize.detect_encoding() now raises a SyntaxError when the
- Issue #4021: tokenize.detect_encoding() now raises a SyntaxError when the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment