cpython: 86b8b035529b (original) (raw)

Mercurial > cpython

changeset 84989:86b8b035529b 3.3

Issue #17998: Fix an internal error in regular expression engine. [#17998]

Serhiy Storchaka storchaka@gmail.com
date Sat, 03 Aug 2013 19🔞38 +0300
parents c503cea0e8c2
children 36702442ffe0 797b1d13d16e ecc8512b427d
files Lib/test/test_re.py Misc/NEWS Modules/_sre.c Modules/sre.h
diffstat 4 files changed, 19 insertions(+), 7 deletions(-)[+] [-] Lib/test/test_re.py 10 Misc/NEWS 2 Modules/_sre.c 12 Modules/sre.h 2

line wrap: on

line diff

--- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1040,6 +1040,16 @@ class ReTests(unittest.TestCase): with self.assertRaisesRegex(sre_constants.error, '?foo'): re.compile('(?P<?foo>)')

+ def run_re_tests(): from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -59,6 +59,8 @@ Core and Builtins Library ------- +- Issue #17998: Fix an internal error in regular expression engine. +

--- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -997,7 +997,7 @@ entrance: TRACE(("|%p|%p|REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, ctx->pattern[1], ctx->pattern[2]));

state->ptr = ctx->ptr; @@ -1081,7 +1081,7 @@ entrance: TRACE(("|%p|%p|MIN_REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, ctx->pattern[1], ctx->pattern[2]));

state->ptr = ctx->ptr; @@ -1180,7 +1180,7 @@ entrance: TRACE(("|%p|%p|MAX_UNTIL %d\n", ctx->pattern, ctx->ptr, ctx->count));

@@ -1194,7 +1194,7 @@ entrance: RETURN_FAILURE; }

@@ -1243,7 +1243,7 @@ entrance: TRACE(("|%p|%p|MIN_UNTIL %d %p\n", ctx->pattern, ctx->ptr, ctx->count, ctx->u.rep->pattern));

@@ -1272,7 +1272,7 @@ entrance: LASTMARK_RESTORE();

--- a/Modules/sre.h +++ b/Modules/sre.h @@ -19,7 +19,7 @@ #if SIZEOF_SIZE_T > 4

define SRE_MAXREPEAT (~(SRE_CODE)0)

#else -# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX + 1u) +# define SRE_MAXREPEAT ((SRE_CODE)PY_SSIZE_T_MAX) #endif typedef struct {