Skip to content

Commit 8d03cbf

Browse files
Don't wrap for single words
1 parent 4b02678 commit 8d03cbf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Lib/test/test_tools/test_i18n.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,17 @@ def test_normalize_nostr(self):
550550
data = normalize(s, 'UTF-8', options)
551551
self.assertEqual(s_expected, data)
552552

553+
def test_normalize_short_width(self):
554+
# required to set up normalize
555+
options = SimpleNamespace(width=3)
556+
make_escapes(True)
557+
558+
s = 'foos'
559+
s_expected = '"foos"'
560+
561+
data = normalize(s, 'UTF-8', options)
562+
self.assertEqual(s_expected, data)
563+
553564

554565
def extract_from_snapshots():
555566
snapshots = {

Tools/i18n/pygettext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def normalize(s, encoding, options):
224224
# while wrapping to options.width.
225225
lines = []
226226
for line in s.splitlines(True):
227-
if len(escape(line, encoding)) > options.width:
227+
if len(escape(line, encoding)) > options.width and ' ' in line: # don't wrap single words
228228
words = _space_splitter(line)
229229
words.reverse()
230230
buf = []

0 commit comments

Comments
 (0)