diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-08-19 19:50:54 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-08-19 19:50:54 (GMT) |
commit | 9d96542b6d1f5c470a60f21d0d8b4ee3edcb17f9 (patch) | |
tree | 68d57f5520858bb5d427211eb3939335a7f43448 /Lib | |
parent | 4d98ca9ff6574d1a76d213b05d1e899e19a2add6 (diff) | |
download | cpython-9d96542b6d1f5c470a60f21d0d8b4ee3edcb17f9.zip cpython-9d96542b6d1f5c470a60f21d0d8b4ee3edcb17f9.tar.gz cpython-9d96542b6d1f5c470a60f21d0d8b4ee3edcb17f9.tar.bz2 |
Issue #18647: Correctly bound calculated min/max width of a subexpression.
Now max width is MAXREPEAT on 32- and 64-bit platforms when one of
subexpressions is unbounded repetition.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/sre_parse.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 9e0501f..f26229f 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -148,7 +148,7 @@ class SubPattern: REPEATCODES = (MIN_REPEAT, MAX_REPEAT) for op, av in self.data: if op is BRANCH: - i = sys.maxsize + i = MAXREPEAT - 1 j = 0 for av in av[1]: l, h = av.getwidth() @@ -166,14 +166,14 @@ class SubPattern: hi = hi + j elif op in REPEATCODES: i, j = av[2].getwidth() - lo = lo + int(i) * av[0] - hi = hi + int(j) * av[1] + lo = lo + i * av[0] + hi = hi + j * av[1] elif op in UNITCODES: lo = lo + 1 hi = hi + 1 elif op == SUCCESS: break - self.width = int(min(lo, sys.maxsize)), int(min(hi, sys.maxsize)) + self.width = min(lo, MAXREPEAT - 1), min(hi, MAXREPEAT) return self.width class Tokenizer: |