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 <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2019-11-13 07:16:33 -06:00
parent 19f2791082
commit 4d6e9cb162
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
1 changed files with 4 additions and 4 deletions

View File

@ -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>{[^}]*})|' # {tag} # nosec
'(?P<wild>\*(?=$|[^\*]))|' # *
'(?P<rec_wild>\*\*)|' # **
'(?P<literal>[^{}\*])') # anything else
r'(?P<wild>\*(?=$|[^\*]))|' # *
r'(?P<rec_wild>\*\*)|' # **
r'(?P<literal>[^{}\*])') # 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']: