diff options
author | Just van Rossum <just@letterror.com> | 2002-06-09 09:08:53 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2002-06-09 09:08:53 (GMT) |
commit | ec5d6b908c25d45ffcf5b5ad60cdb51b38b6a769 (patch) | |
tree | e5bdc44ae531506096780a7ead19b78d59f2bce6 /Tools | |
parent | 47df99d57527a9b1a940e87fd4e0164caaf5d029 (diff) | |
download | cpython-ec5d6b908c25d45ffcf5b5ad60cdb51b38b6a769.zip cpython-ec5d6b908c25d45ffcf5b5ad60cdb51b38b6a769.tar.gz cpython-ec5d6b908c25d45ffcf5b5ad60cdb51b38b6a769.tar.bz2 |
escape 8-bit chars when generating .py files. fixes bug #566302
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/bgen/bgen/scantools.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py index 768b3b7..9256c4f 100644 --- a/Tools/bgen/bgen/scantools.py +++ b/Tools/bgen/bgen/scantools.py @@ -433,6 +433,7 @@ if missing: raise "Missing Types" def dosymdef(self, match): name, defn = match.group('name', 'defn') + defn = escape8bit(defn) if self.debug: self.report("\tsym: name=%s, defn=%s" % (`name`, `defn`)) if not name in self.blacklistnames: @@ -638,7 +639,21 @@ class Scanner_OSX(Scanner): self.whole_pat = self.type_pat + self.name_pat + self.args_pat self.sym_pat = "^[ \t]*(?P<name>[a-zA-Z0-9_]+)[ \t]*=" + \ "[ \t]*(?P<defn>[-0-9_a-zA-Z'\"\(][^\t\n,;}]*),?" - + +_8bit = re.compile(r"[\200-\377]") + +def escape8bit(s): + if _8bit.search(s) is not None: + out = [] + for c in s: + o = ord(c) + if o >= 128: + out.append("\\" + hex(o)[1:]) + else: + out.append(c) + s = "".join(out) + return s + def test(): input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h" output = "@aespecs.py" |