Quiece 'invalid escape sequence' deprecation msg

Glance tests are currently too verbose for subunit and make
them randomly fail under python 3.

Using raw strings should avoid the DeprecationWarnings around
'invalid escape sequence' being used with the re module.

Change-Id: I14c381ac4b17ca4c5755ed78c55dc44362ab37ef
This commit is contained in:
Thierry Carrez 2019-04-03 17:09:47 +02:00
parent 117cecfb4c
commit 84c8f9e3ff
4 changed files with 4 additions and 4 deletions

View File

@ -112,7 +112,7 @@ def get_remaining_quota(context, db_api, image_id=None):
# set quota must have a number optionally followed by B, KB, MB,
# GB or TB without any spaces in between
pattern = re.compile('^(\d+)((K|M|G|T)?B)?$')
pattern = re.compile(r'^(\d+)((K|M|G|T)?B)?$')
match = pattern.match(users_quota)
if not match:

View File

@ -676,7 +676,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
if not pointer.startswith('/'):
msg = _('Pointer `%s` does not start with "/".') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
if re.search('/\s*?/', pointer[1:]):
if re.search(r'/\s*?/', pointer[1:]):
msg = _('Pointer `%s` contains adjacent "/".') % pointer
raise webob.exc.HTTPBadRequest(explanation=msg)
if len(pointer) > 1 and pointer.endswith('/'):

View File

@ -516,7 +516,7 @@ def is_valid_hostname(hostname):
def is_valid_fqdn(fqdn):
"""Verify whether a host is a valid FQDN."""
return re.match('^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', fqdn) is not None
return re.match(r'^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', fqdn) is not None
def parse_valid_host_port(host_port):

View File

@ -395,7 +395,7 @@ def _export_data_to_file(meta, path):
namespace_table = get_metadef_namespaces_table(meta)
namespaces = namespace_table.select().execute().fetchall()
pattern = re.compile('[\W_]+', re.UNICODE)
pattern = re.compile(r'[\W_]+', re.UNICODE)
for id, namespace in enumerate(namespaces, start=1):
namespace_id = namespace['id']