diff options
author | shadchin <shadchin@yandex-team.com> | 2023-12-13 02:43:57 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2023-12-13 03:08:48 +0300 |
commit | 5b48aabc614c6d407f885f3b228dc484ad4c5ba9 (patch) | |
tree | 602eb5cc5d85bf730c1de1fa50a13c2ee552830d /contrib/tools/python3/src/Lib/re/_parser.py | |
parent | 35d7049b38602e8cbfcd3f96257329a1abce947e (diff) | |
download | ydb-5b48aabc614c6d407f885f3b228dc484ad4c5ba9.tar.gz |
Update Python 3 to 3.11.7
Diffstat (limited to 'contrib/tools/python3/src/Lib/re/_parser.py')
-rw-r--r-- | contrib/tools/python3/src/Lib/re/_parser.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/contrib/tools/python3/src/Lib/re/_parser.py b/contrib/tools/python3/src/Lib/re/_parser.py index 6b715f5403..c795a7fb00 100644 --- a/contrib/tools/python3/src/Lib/re/_parser.py +++ b/contrib/tools/python3/src/Lib/re/_parser.py @@ -68,6 +68,10 @@ FLAGS = { TYPE_FLAGS = SRE_FLAG_ASCII | SRE_FLAG_LOCALE | SRE_FLAG_UNICODE GLOBAL_FLAGS = SRE_FLAG_DEBUG | SRE_FLAG_TEMPLATE +# Maximal value returned by SubPattern.getwidth(). +# Must be larger than MAXREPEAT, MAXCODE and sys.maxsize. +MAXWIDTH = 1 << 64 + class State: # keeps track of state for parsing def __init__(self): @@ -178,7 +182,7 @@ class SubPattern: lo = hi = 0 for op, av in self.data: if op is BRANCH: - i = MAXREPEAT - 1 + i = MAXWIDTH j = 0 for av in av[1]: l, h = av.getwidth() @@ -197,7 +201,10 @@ class SubPattern: elif op in _REPEATCODES: i, j = av[2].getwidth() lo = lo + i * av[0] - hi = hi + j * av[1] + if av[1] == MAXREPEAT and j: + hi = MAXWIDTH + else: + hi = hi + j * av[1] elif op in _UNITCODES: lo = lo + 1 hi = hi + 1 @@ -217,7 +224,7 @@ class SubPattern: hi = hi + j elif op is SUCCESS: break - self.width = min(lo, MAXREPEAT - 1), min(hi, MAXREPEAT) + self.width = min(lo, MAXWIDTH), min(hi, MAXWIDTH) return self.width class Tokenizer: |