diff --git a/caffe2/contrib/cuda-convnet2/python_util/data.py b/caffe2/contrib/cuda-convnet2/python_util/data.py index d8c8ff1a4c50a..591dbccb8d5bf 100644 --- a/caffe2/contrib/cuda-convnet2/python_util/data.py +++ b/caffe2/contrib/cuda-convnet2/python_util/data.py @@ -29,7 +29,7 @@ def run(self): self.tgt += [unpickle(self.path)] class DataProvider: - BATCH_REGEX = re.compile('^data_batch_(\d+)(\.\d+)?$') + BATCH_REGEX = re.compile(r'^data_batch_(\d+)(\.\d+)?$') def __init__(self, data_dir, batch_range=None, init_epoch=1, init_batchnum=None, dp_params={}, test=False): if batch_range == None: batch_range = DataProvider.get_batch_nums(data_dir) diff --git a/caffe2/contrib/cuda-convnet2/python_util/util.py b/caffe2/contrib/cuda-convnet2/python_util/util.py index b3b62111a4f3e..c0a8a4a078009 100644 --- a/caffe2/contrib/cuda-convnet2/python_util/util.py +++ b/caffe2/contrib/cuda-convnet2/python_util/util.py @@ -48,7 +48,7 @@ def unpickle(filename): return dict def is_intel_machine(): - VENDOR_ID_REGEX = re.compile('^vendor_id\s+: (\S+)') + VENDOR_ID_REGEX = re.compile(r'^vendor_id\s+: (\S+)') f = open('/proc/cpuinfo') for line in f: m = VENDOR_ID_REGEX.match(line) diff --git a/caffe2/python/docs/parser.py b/caffe2/python/docs/parser.py index 0d57e4d9adebd..024989c97e258 100644 --- a/caffe2/python/docs/parser.py +++ b/caffe2/python/docs/parser.py @@ -19,10 +19,10 @@ class Parser(object): ('```(.+?)```', lambda m, f: f.addCode(m.group(1)) ), - ('((( {2})+)(\S.*)(\n\s*\n|\n))+', + (r'((( {2})+)(\S.*)(\n\s*\n|\n))+', lambda m, f: f.addCode(m.group(0)) ), - ('([^\.])\n', + (r'([^\.])\n', lambda m, f: f.addRaw('{c} '.format(c=m.group(1))) or True ), ('`(.+?)`', @@ -30,13 +30,13 @@ class Parser(object): ), # Make links clickable ('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]' - '|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', + r'|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', lambda m, f: f.addLink(m.group(0), m.group(0)) ), - ('\*\*(.+?)\*\*', + (r'\*\*(.+?)\*\*', lambda m, f: f.addEmphasis(m.group(1), 2) ), - ('\*(.+?)\*', + (r'\*(.+?)\*', lambda m, f: f.addEmphasis(m.group(1), 1) ), ] diff --git a/scripts/diagnose_protobuf.py b/scripts/diagnose_protobuf.py index f3209a4012502..dd8b7090c5e42 100644 --- a/scripts/diagnose_protobuf.py +++ b/scripts/diagnose_protobuf.py @@ -50,7 +50,7 @@ print('DEBUG: err: ' + err) native_protobuf_installed = False else: - tmp = re.search('\d\.\d\.\d', out) + tmp = re.search(r'\d\.\d\.\d', out) if tmp: native_version = tmp.group(0) native_protobuf_installed = True diff --git a/tools/amd_build/pyHIPIFY/hipify_python.py b/tools/amd_build/pyHIPIFY/hipify_python.py index cc8e74ebde994..db14d7cee824f 100755 --- a/tools/amd_build/pyHIPIFY/hipify_python.py +++ b/tools/amd_build/pyHIPIFY/hipify_python.py @@ -613,7 +613,7 @@ def disable_function(input_string, function, replace_style): else: # Automatically detect signature. the_match = re.search(r"(((.*) (\*)?)({0})(\([^{{)]*\)))\s*{{".format( - function.replace("(", "\(").replace(")", "\)")), input_string) + function.replace("(", r"\(").replace(")", r"\)")), input_string) if the_match is None: return input_string @@ -1177,7 +1177,7 @@ def extract_arguments(start, string): return arguments -RE_HIP_LAUNCH_KERNEL_GGL = re.compile("hipLaunchKernelGGL\(") +RE_HIP_LAUNCH_KERNEL_GGL = re.compile(r"hipLaunchKernelGGL\(") # Add static_cast to ensure that the type of kernel arguments matches that in the corresponding kernel definition