Skip to content

Commit 8d5f84f

Browse files
Use more complex pattern
1 parent fbe5b93 commit 8d5f84f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Tools/i18n/pygettext.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def escape_nonascii(s, encoding):
214214
return ''.join(escapes[b] for b in s.encode(encoding))
215215

216216

217-
_space_splitter = re.compile(r'(\s+)')
217+
_space_splitter = re.compile(r'\s+|\S+\s*')
218218

219219
def normalize(s, encoding, prefix, options):
220220
# This converts the various Python string types into a format that is
@@ -224,7 +224,8 @@ def normalize(s, encoding, prefix, options):
224224
for line in s.splitlines(True):
225225
escaped_line = escape(line, encoding)
226226
if len(escaped_line) + len(prefix) + 2 > options.width and _space_splitter.search(line): # don't wrap single words
227-
words = _space_splitter.split(line)
227+
words = _space_splitter.findall(line)
228+
words = [w for w in words if w]
228229
words.reverse()
229230
buf = []
230231
size = 0

0 commit comments

Comments
 (0)