Skip to content

Commit

Permalink
MAXWIDTH is not part of sre_constants
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaIng authored Dec 7, 2023
1 parent e4dbb4f commit b31ef8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ def get_regexp_width(expr: str) -> Union[Tuple[int, int], List[int]]:
# sre_parse does not support the new features in regex. To not completely fail in that case,
# we manually test for the most important info (whether the empty string is matched)
c = regex.compile(regexp_final)
# Python 3.11.7 introducded sre_constants.MAXWIDTH that is used instead of MAXREPEAT
# Python 3.11.7 introducded sre_parse.MAXWIDTH that is used instead of MAXREPEAT
# See lark-parser/lark#1376 and python/cpython#109859
MAXWIDTH = getattr(sre_constants, "MAXWIDTH", sre_constants.MAXREPEAT)
MAXWIDTH = getattr(sre_parse, "MAXWIDTH", sre_constants.MAXREPEAT)
if c.match('') is None:
# MAXREPEAT is a none pickable subclass of int, therefore needs to be converted to enable caching
return 1, int(MAXWIDTH)
Expand Down

0 comments on commit b31ef8f

Please sign in to comment.