Commit f2c89bef authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #17156: pygettext.py now correctly escapes non-ascii characters.

parent 00be2e02
...@@ -202,6 +202,8 @@ Core and Builtins ...@@ -202,6 +202,8 @@ Core and Builtins
Library Library
------- -------
- Issue #17156: pygettext.py now correctly escapes non-ascii characters.
- Issue #7358: cStringIO.StringIO now supports writing to and reading from - Issue #7358: cStringIO.StringIO now supports writing to and reading from
a stream larger than 2 GiB on 64-bit systems. a stream larger than 2 GiB on 64-bit systems.
......
...@@ -208,6 +208,7 @@ escapes = [] ...@@ -208,6 +208,7 @@ escapes = []
def make_escapes(pass_iso8859): def make_escapes(pass_iso8859):
global escapes global escapes
escapes = [chr(i) for i in range(256)]
if pass_iso8859: if pass_iso8859:
# Allow iso-8859 characters to pass through so that e.g. 'msgid # Allow iso-8859 characters to pass through so that e.g. 'msgid
# "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise we # "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise we
...@@ -215,11 +216,9 @@ def make_escapes(pass_iso8859): ...@@ -215,11 +216,9 @@ def make_escapes(pass_iso8859):
mod = 128 mod = 128
else: else:
mod = 256 mod = 256
for i in range(256): for i in range(mod):
if 32 <= (i % mod) <= 126: if not(32 <= i <= 126):
escapes.append(chr(i)) escapes[i] = "\\%03o" % i
else:
escapes.append("\\%03o" % i)
escapes[ord('\\')] = '\\\\' escapes[ord('\\')] = '\\\\'
escapes[ord('\t')] = '\\t' escapes[ord('\t')] = '\\t'
escapes[ord('\r')] = '\\r' escapes[ord('\r')] = '\\r'
...@@ -593,7 +592,7 @@ def main(): ...@@ -593,7 +592,7 @@ def main():
fp.close() fp.close()
# calculate escapes # calculate escapes
make_escapes(options.escape) make_escapes(not options.escape)
# calculate all keywords # calculate all keywords
options.keywords.extend(default_keywords) options.keywords.extend(default_keywords)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment