mirror of https://github.com/python/cpython
gh-106566: Optimize (?!) in regular expressions (GH-106567)
This commit is contained in:
parent
50e3cc9748
commit
ed64204716
|
@ -773,8 +773,10 @@ def _parse(source, state, verbose, nested, first=False):
|
|||
source.tell() - start)
|
||||
if char == "=":
|
||||
subpatternappend((ASSERT, (dir, p)))
|
||||
else:
|
||||
elif p:
|
||||
subpatternappend((ASSERT_NOT, (dir, p)))
|
||||
else:
|
||||
subpatternappend((FAILURE, ()))
|
||||
continue
|
||||
|
||||
elif char == "(":
|
||||
|
|
|
@ -2362,6 +2362,9 @@ class ReTests(unittest.TestCase):
|
|||
p.terminate()
|
||||
p.join()
|
||||
|
||||
def test_fail(self):
|
||||
self.assertEqual(re.search(r'12(?!)|3', '123')[0], '3')
|
||||
|
||||
|
||||
def get_debug_out(pat):
|
||||
with captured_stdout() as out:
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Optimize ``(?!)`` (pattern which alwais fails) in regular expressions.
|
Loading…
Reference in New Issue