summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-05-28 23:01:28 (GMT)
committerGuido van Rossum <guido@python.org>1996-05-28 23:01:28 (GMT)
commit9e6aa9d55b194e7499e39af69e675fd7a5d9639f (patch)
tree65cb12804a2827bba0ca5f8e59cb8bdb6557b0e1 /Lib
parentdc42b8aa3dc22fc4bbe79eff5f3c1315eddb6388 (diff)
downloadcpython-9e6aa9d55b194e7499e39af69e675fd7a5d9639f.zip
cpython-9e6aa9d55b194e7499e39af69e675fd7a5d9639f.tar.gz
cpython-9e6aa9d55b194e7499e39af69e675fd7a5d9639f.tar.bz2
avoid eval() like the plague
Diffstat (limited to 'Lib')
-rw-r--r--Lib/regsub.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/regsub.py b/Lib/regsub.py
index 7eb175b..507e542 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