From 59b68656f846973840953220c4780f3558b59fb8 Mon Sep 17 00:00:00 2001 From: Fredrik Lundh Date: Tue, 18 Sep 2001 20:55:24 +0000 Subject: fixed #449964: sre.sub raises an exception if the template contains a \g group reference followed by a character escape (also restructured a few things on the way to fixing #449000) --- Lib/sre_parse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Lib/sre_parse.py') diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index af1edbf3d2..7d9b8899bc 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -647,9 +647,9 @@ def parse_template(source, pattern): p.append((LITERAL, literal)) sep = source[:0] if type(sep) is type(""): - char = chr + makechar = chr else: - char = unichr + makechar = unichr while 1: this = s.get() if this is None: @@ -693,14 +693,14 @@ def parse_template(source, pattern): break if not code: this = this[1:] - code = LITERAL, char(atoi(this[-6:], 8) & 0xff) + code = LITERAL, makechar(atoi(this[-6:], 8) & 0xff) if code[0] is LITERAL: literal(code[1]) else: a(code) else: try: - this = char(ESCAPES[this][1]) + this = makechar(ESCAPES[this][1]) except KeyError: pass literal(this) -- cgit v1.2.1