summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-11-22 22:04:39 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-11-22 22:04:39 (GMT)
commit726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef (patch)
tree9ca6ccf2b5ee118ccf1fd0e7b47fcaf9f833cda7 /Lib
parente3d75c63cd100675f96cd5c152ccd021ba9e6ebb (diff)
downloadcpython-726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef.zip
cpython-726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef.tar.gz
cpython-726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef.tar.bz2
Issue #28765: _sre.compile() now checks the type of groupindex and indexgroup
groupindex must a dictionary and indexgroup must be a tuple. Previously, indexgroup was a list. Use a tuple to reduce the memory usage.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/sre_compile.py2
-rw-r--r--Lib/test/test_re.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 420d83d..2cc3900 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -576,5 +576,5 @@ def compile(p, flags=0):
return _sre.compile(
pattern, flags | p.pattern.flags, code,
p.pattern.groups-1,
- groupindex, indexgroup
+ groupindex, tuple(indexgroup)
)
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 84131d2..6896b4d 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1506,7 +1506,7 @@ class ReTests(unittest.TestCase):
long_overflow = 2**128
self.assertRaises(TypeError, re.finditer, "a", {})
with self.assertRaises(OverflowError):
- _sre.compile("abc", 0, [long_overflow], 0, [], [])
+ _sre.compile("abc", 0, [long_overflow], 0, {}, ())
with self.assertRaises(TypeError):
_sre.compile({}, 0, [], 0, [], [])