Skip to content

Commit

Permalink
Adjust imports for Python 3.11
Browse files Browse the repository at this point in the history
sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308
  • Loading branch information
The-Compiler committed Apr 26, 2022
1 parent 8a77e42 commit 1b62465
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ def deserialize(cls, data, namespace, memo):
except ImportError:
regex = None

import sre_parse
import sre_constants
try: # Python 3.11
import re._parser as sre_parse
import re._constants as sre_constants
except ImportError:
import sre_parse
import sre_constants

categ_pattern = re.compile(r'\\p{[A-Za-z_]+}')

def get_regexp_width(expr):
Expand Down

0 comments on commit 1b62465

Please sign in to comment.