From: Guido van Rossum Date: Tue, 28 May 1996 23:01:28 +0000 (+0000) Subject: avoid eval() like the plague X-Git-Tag: v1.4b1~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e6aa9d55b194e7499e39af69e675fd7a5d9639f;p=python avoid eval() like the plague --- diff --git a/Lib/regsub.py b/Lib/regsub.py index 7eb175b60e..507e542882 100644 --- a/Lib/regsub.py +++ b/Lib/regsub.py @@ -107,6 +107,7 @@ def expand(repl, regs, str): return repl new = '' i = 0 + ord0 = ord('0') while i < len(repl): c = repl[i]; i = i+1 if c <> '\\' or i >= len(repl): @@ -114,7 +115,7 @@ def expand(repl, regs, str): else: c = repl[i]; i = i+1 if '0' <= c <= '9': - a, b = regs[eval(c)] + a, b = regs[ord(c)-ord0] new = new + str[a:b] elif c == '\\': new = new + c