summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-08-16 20:31:12 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-08-16 20:31:12 (GMT)
commitc593056744559102f79f82c8b87da05d9a0450ca (patch)
treefe06dd9c9f8ab35f2d8d59a99c8e488b4655b23a /Lib
parent05eafa887b8c8046c0045f53eac1383caaed2b6e (diff)
downloadcpython-c593056744559102f79f82c8b87da05d9a0450ca.zip
cpython-c593056744559102f79f82c8b87da05d9a0450ca.tar.gz
cpython-c593056744559102f79f82c8b87da05d9a0450ca.tar.bz2
Fix the default placeholder in textwrap.shorten() to be " [...]".
For some reason I forgot to do it before committing the patch in issue #18585.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_textwrap.py12
-rw-r--r--Lib/textwrap.py4
2 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index 20b7655..36c15cc 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -786,11 +786,11 @@ class ShortenTestCase(BaseTestCase):
# Simple case: just words, spaces, and a bit of punctuation
text = "Hello there, how are you this fine day? I'm glad to hear it!"
- self.check_shorten(text, 18, "Hello there, (...)")
+ self.check_shorten(text, 18, "Hello there, [...]")
self.check_shorten(text, len(text), text)
self.check_shorten(text, len(text) - 1,
"Hello there, how are you this fine day? "
- "I'm glad to (...)")
+ "I'm glad to [...]")
def test_placeholder(self):
text = "Hello there, how are you this fine day? I'm glad to hear it!"
@@ -816,13 +816,13 @@ class ShortenTestCase(BaseTestCase):
"breaks and tabs too.")
self.check_shorten(text, 61,
"This is a paragraph that already has line "
- "breaks and (...)")
+ "breaks and [...]")
self.check_shorten("hello world! ", 12, "hello world!")
- self.check_shorten("hello world! ", 11, "hello (...)")
+ self.check_shorten("hello world! ", 11, "hello [...]")
# The leading space is trimmed from the placeholder
# (it would be ugly otherwise).
- self.check_shorten("hello world! ", 10, "(...)")
+ self.check_shorten("hello world! ", 10, "[...]")
def test_width_too_small_for_placeholder(self):
wrapper = TextWrapper(width=8)
@@ -831,7 +831,7 @@ class ShortenTestCase(BaseTestCase):
wrapper.shorten("x" * 20, placeholder="(.......)")
def test_first_word_too_long_but_placeholder_fits(self):
- self.check_shorten("Helloo", 5, "(...)")
+ self.check_shorten("Helloo", 5, "[...]")
if __name__ == '__main__':
diff --git a/Lib/textwrap.py b/Lib/textwrap.py
index b19f124..27ebc16 100644
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -19,7 +19,7 @@ __all__ = ['TextWrapper', 'wrap', 'fill', 'dedent', 'indent']
# since 0xa0 is not in range(128).
_whitespace = '\t\n\x0b\x0c\r '
-_default_placeholder = ' (...)'
+_default_placeholder = ' [...]'
class TextWrapper:
"""
@@ -376,7 +376,7 @@ def shorten(text, width, *, placeholder=_default_placeholder, **kwargs):
>>> textwrap.shorten("Hello world!", width=12)
'Hello world!'
>>> textwrap.shorten("Hello world!", width=11)
- 'Hello (...)'
+ 'Hello [...]'
"""
w = TextWrapper(width=width, **kwargs)
return w.shorten(text, placeholder=placeholder)