Skip to content

Commit

Permalink
Remove fullmatch kludge
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Mar 19, 2022
1 parent 51e823d commit c0d54ce
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/attr/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ def matches_re(regex, flags=0, func=None):
.. versionadded:: 19.2.0
.. versionchanged:: 21.3.0 *regex* can be a pre-compiled pattern.
"""
fullmatch = getattr(re, "fullmatch", None)
valid_funcs = (fullmatch, None, re.search, re.match)
valid_funcs = (re.fullmatch, None, re.search, re.match)
if func not in valid_funcs:
raise ValueError(
"'func' must be one of {}.".format(
Expand All @@ -205,13 +204,8 @@ def matches_re(regex, flags=0, func=None):
match_func = pattern.match
elif func is re.search:
match_func = pattern.search
elif fullmatch:
else:
match_func = pattern.fullmatch
else: # Python 2 fullmatch emulation (https://bugs.python.org/issue16203)
pattern = re.compile(
r"(?:{})\Z".format(pattern.pattern), pattern.flags
)
match_func = pattern.match

return _MatchesReValidator(pattern, match_func)

Expand Down

0 comments on commit c0d54ce

Please sign in to comment.