Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65d4bc6

Browse files
author
Fredrik Lundh
committed
Fixed negative lookahead/lookbehind. Closes bug #115618.
1 parent 8429448 commit 65d4bc6

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

Lib/test/re_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,6 @@
615615
# bug 112468
616616
('(', '', SYNTAX_ERROR),
617617
('[\\41]', '!', SUCCEED, 'found', '!'),
618+
# bug 115618
619+
(r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
618620
]

Modules/_sre.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* 2000-09-02 fl return -1 instead of None for start/end/span
2121
* 2000-09-20 fl added expand method
2222
* 2000-09-21 fl don't use the buffer interface for unicode strings
23+
* 2000-10-03 fl fixed assert_not primitive
2324
*
2425
* Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved.
2526
*
@@ -774,8 +775,6 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
774775
i = SRE_MATCH(state, pattern + 2, level + 1);
775776
if (i <= 0)
776777
return i;
777-
if (pattern[1] > 0 && state->ptr != ptr)
778-
return SRE_ERROR_STATE;
779778
pattern += pattern[0];
780779
break;
781780

@@ -791,8 +790,6 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
791790
return i;
792791
if (i)
793792
return 0;
794-
if (pattern[1] > 0 && state->ptr != ptr)
795-
return SRE_ERROR_STATE;
796793
pattern += pattern[0];
797794
break;
798795

0 commit comments

Comments
 (0)