This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients annesylvie, pitrou, serhiy.storchaka, terry.reedy
Date 2021-03-20.00:16:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Verified in 3.10.0a6 that change is at 3 !s.  I agree that is is a bug relative to the doc.

The issue is that 'world!!!' is 8 chars, and by default, wrap splits that into 'w' and 'orld!!!' and add ' w' to 'hello'.
>>> sh('hello world!!!', width=7)
['hello w', 'orld!!!']

A solution is to not break long words.
>>> sh('hello world!!!', width=7, placeholder='', break_long_words=False)


>>> sh('hello!!!! world!!!', width=7, placeholder='', break_long_words=False)


>>> sh('hello!!!! world!!!', width=7, placeholder='')

The docstring and doc say "enough words are dropped from the end so that the remaining words plus the placeholder fit within width:".  Taking this literally, '' is correct.  So a fix would be to add "break_long_words=False" to options if break_long_words not in options.

Antoine, you last touched the shorten docstring.  Serhiy, you last touched its code.  What do you two think?
Date User Action Args
2021-03-20 00:16:07terry.reedysetrecipients: + terry.reedy, pitrou, serhiy.storchaka, annesylvie
2021-03-20 00:16:07terry.reedysetmessageid: <>
2021-03-20 00:16:07terry.reedylinkissue43518 messages
2021-03-20 00:16:07terry.reedycreate