Message389129
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)
'hello'
Then
>>> sh('hello!!!! world!!!', width=7, placeholder='', break_long_words=False)
''
versus
>>> sh('hello!!!! world!!!', width=7, placeholder='')
'hello!!'
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:07 | terry.reedy | set | recipients:
+ terry.reedy, pitrou, serhiy.storchaka, annesylvie |
2021-03-20 00:16:07 | terry.reedy | set | messageid: <1616199367.91.0.433068143758.issue43518@roundup.psfhosted.org> |
2021-03-20 00:16:07 | terry.reedy | link | issue43518 messages |
2021-03-20 00:16:07 | terry.reedy | create | |
|