[Python-checkins] cpython: Fix the default placeholder in textwrap.shorten() to be " [...]".

antoine.pitrou python-checkins at python.org
Fri Aug 16 22:31:22 CEST 2013


http://hg.python.org/cpython/rev/be5481bf4c57
changeset:   85203:be5481bf4c57
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Fri Aug 16 22:31:12 2013 +0200
summary:
  Fix the default placeholder in textwrap.shorten() to be " [...]".
For some reason I forgot to do it before committing the patch in issue #18585.

files:
  Doc/library/textwrap.rst  |   6 +++---
  Lib/test/test_textwrap.py |  12 ++++++------
  Lib/textwrap.py           |   4 ++--
  3 files changed, 11 insertions(+), 11 deletions(-)


diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst
--- a/Doc/library/textwrap.rst
+++ b/Doc/library/textwrap.rst
@@ -40,7 +40,7 @@
    :func:`wrap`.
 
 
-.. function:: shorten(text, width=70, *, placeholder=" (...)")
+.. function:: shorten(text, width=70, *, placeholder=" [...]")
 
    Collapse and truncate the given text to fit in the given width.
 
@@ -51,7 +51,7 @@
       >>> textwrap.shorten("Hello  world!", width=12)
       'Hello world!'
       >>> textwrap.shorten("Hello  world!", width=11)
-      'Hello (...)'
+      'Hello [...]'
       >>> textwrap.shorten("Hello world", width=10, placeholder="...")
       'Hello...'
 
@@ -268,7 +268,7 @@
       containing the wrapped paragraph.
 
 
-   .. function:: shorten(text, *, placeholder=" (...)")
+   .. function:: shorten(text, *, placeholder=" [...]")
 
       Collapse and truncate the given text to fit in :attr:`width`
       characters.
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -786,11 +786,11 @@
         # 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 @@
                              "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 @@
             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
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -19,7 +19,7 @@
 # since 0xa0 is not in range(128).
 _whitespace = '\t\n\x0b\x0c\r '
 
-_default_placeholder = ' (...)'
+_default_placeholder = ' [...]'
 
 class TextWrapper:
     """
@@ -376,7 +376,7 @@
         >>> 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)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list