mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-23689: re module, fix memory leak when a match is terminated by a signal or memory allocation failure (GH-32283)
This commit is contained in:
parent
b82cdd1dac
commit
6e3eee5c11
9 changed files with 151 additions and 71 deletions
|
@ -1643,9 +1643,12 @@ 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, {}, (), 0)
|
||||
with self.assertRaises(TypeError):
|
||||
_sre.compile({}, 0, [], 0, [], [])
|
||||
_sre.compile({}, 0, [], 0, [], [], 0)
|
||||
with self.assertRaises(RuntimeError):
|
||||
# invalid repeat_count -1
|
||||
_sre.compile("abc", 0, [1], 0, {}, (), -1)
|
||||
|
||||
def test_search_dot_unicode(self):
|
||||
self.assertTrue(re.search("123.*-", '123abc-'))
|
||||
|
@ -2334,6 +2337,27 @@ POSSESSIVE_REPEAT 0 1
|
|||
14. SUCCESS
|
||||
''')
|
||||
|
||||
def test_repeat_index(self):
|
||||
self.assertEqual(get_debug_out(r'(?:ab)*?(?:cd)*'), '''\
|
||||
MIN_REPEAT 0 MAXREPEAT
|
||||
LITERAL 97
|
||||
LITERAL 98
|
||||
MAX_REPEAT 0 MAXREPEAT
|
||||
LITERAL 99
|
||||
LITERAL 100
|
||||
|
||||
0. INFO 4 0b0 0 MAXREPEAT (to 5)
|
||||
5: REPEAT 8 0 MAXREPEAT 0 (to 14)
|
||||
10. LITERAL 0x61 ('a')
|
||||
12. LITERAL 0x62 ('b')
|
||||
14: MIN_UNTIL
|
||||
15. REPEAT 8 0 MAXREPEAT 1 (to 24)
|
||||
20. LITERAL 0x63 ('c')
|
||||
22. LITERAL 0x64 ('d')
|
||||
24: MAX_UNTIL
|
||||
25. SUCCESS
|
||||
''')
|
||||
|
||||
|
||||
class PatternReprTests(unittest.TestCase):
|
||||
def check(self, pattern, expected):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue