From 4d6e9cb16228e21c551e0d894c45f2a137688cca Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 13 Nov 2019 07:16:33 -0600 Subject: [PATCH] Fix DeprecationWarning: invalid escape sequence issues Some regex strings contain invalid escape sequences for normal strings, causing newer version of Python to emit DeprecationWarning messages. This updates those instances to raw strings so they are not interpreted as invalid. Change-Id: I28ac26516bacab36578a5a7f6ec7f9dcf7d7eeb1 Signed-off-by: Sean McGinnis --- keystonemiddleware/auth_token/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/keystonemiddleware/auth_token/__init__.py b/keystonemiddleware/auth_token/__init__.py index b29b63a0..d961f591 100644 --- a/keystonemiddleware/auth_token/__init__.py +++ b/keystonemiddleware/auth_token/__init__.py @@ -282,14 +282,14 @@ def _path_matches(request_path, path_pattern): # The fnmatch module doesn't provide the ability to match * versus **, # so convert to regex. token_regex = (r'(?P{[^}]*})|' # {tag} # nosec - '(?P\*(?=$|[^\*]))|' # * - '(?P\*\*)|' # ** - '(?P[^{}\*])') # anything else + r'(?P\*(?=$|[^\*]))|' # * + r'(?P\*\*)|' # ** + r'(?P[^{}\*])') # anything else path_regex = '' for match in re.finditer(token_regex, path_pattern): token = match.groupdict() if token['tag'] or token['wild']: - path_regex += '[^\/]+' + path_regex += r'[^\/]+' if token['rec_wild']: path_regex += '.*' if token['literal']: