Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7733e12

Browse files
committed
Two buglet fixes. Peter Funk caught the bug in make_escapes:
This will fold all ISO 8859 chars from the upper half of the charset into the lower half, which is ...ummm.... unintened. The second is a typo in the reference to options.escape in main().
1 parent c8f0892 commit 7733e12

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Tools/i18n/pygettext.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,15 @@ def usage(code, msg=''):
165165

166166
def make_escapes(pass_iso8859):
167167
global escapes
168+
if pass_iso8859:
169+
# Allow iso-8859 characters to pass through so that e.g. 'msgid
170+
# "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise we
171+
# escape any character outside the 32..126 range.
172+
mod = 128
173+
else:
174+
mod = 256
168175
for i in range(256):
169-
if pass_iso8859:
170-
# Allow iso-8859 characters to pass through so that e.g. 'msgid
171-
# "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise
172-
# we escape any character outside the 32..126 range.
173-
i = i % 128
174-
if 32 <= i <= 126:
176+
if 32 <= (i % mod) <= 126:
175177
escapes.append(chr(i))
176178
else:
177179
escapes.append("\\%03o" % i)
@@ -373,7 +375,7 @@ class Options:
373375
options.excludefilename = arg
374376

375377
# calculate escapes
376-
make_escapes(options.escapes)
378+
make_escapes(options.escape)
377379

378380
# calculate all keywords
379381
options.keywords.extend(default_keywords)

0 commit comments

Comments
 (0)