Skip to content

Commit

Permalink
No longer use undocumented module "sre_constants" (#379)
Browse files Browse the repository at this point in the history
Closes #378.
  • Loading branch information
serhiy-storchaka committed Mar 29, 2022
1 parent ac30c72 commit 3c03942
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions pyparsing/core.py
Expand Up @@ -23,7 +23,6 @@
import copy
import warnings
import re
import sre_constants
import sys
from collections.abc import Iterable
import traceback
Expand Down Expand Up @@ -2783,7 +2782,7 @@ def __init__(

try:
self.re = re.compile(self.reString)
except sre_constants.error:
except re.error:
self.re = None
else:
self.re_match = self.re.match
Expand Down Expand Up @@ -2966,7 +2965,7 @@ def re(self):
else:
try:
return re.compile(self.pattern, self.flags)
except sre_constants.error:
except re.error:
raise ValueError(
"invalid pattern ({!r}) passed to Regex".format(self.pattern)
)
Expand Down Expand Up @@ -3188,7 +3187,7 @@ def __init__(
self.re = re.compile(self.pattern, self.flags)
self.reString = self.pattern
self.re_match = self.re.match
except sre_constants.error:
except re.error:
raise ValueError(
"invalid pattern {!r} passed to Regex".format(self.pattern)
)
Expand Down
2 changes: 1 addition & 1 deletion pyparsing/helpers.py
Expand Up @@ -312,7 +312,7 @@ def one_of(

return ret

except sre_constants.error:
except re.error:
warnings.warn(
"Exception creating Regex for one_of, building MatchFirst", stacklevel=2
)
Expand Down

0 comments on commit 3c03942

Please sign in to comment.