Skip to contentSkip to conversation

Use raw strings for regex with backslash-char pair

PATCH New [email protected] 1 participant 1 message May 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use raw strings for regex with backslash-char pair

From: Ed Beroset <[email protected]>

As per
https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
this removes some SyntaxWarnings that occurred because of using backslash-char pairs in regex strings. This simply changes those strings to be raw strings instead.

---
 makewrappers | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
makewrappers +4 -4
index cf5ad60..1e80e30 100755
@@ -127,7 +127,7 @@ class Argument:
             self.vararg = False
 
         # try for a function pointer
-        match = re.match('(.*)\(\*([a-zA-Z0-9$_]*)\)\((.*)\)', text)
+        match = re.match(r'(.*)\(\*([a-zA-Z0-9$_]*)\)\((.*)\)', text)
         if match:
             self.function_pointer = True
             self.args = match.group(3)
@@ -135,7 +135,7 @@ class Argument:
             self.name = match.group(2).rstrip()
         else:
             # plain declaration
-            match = re.match('(.*[ *])\(?\*?([a-zA-Z0-9$_]*)\)?', text)
+            match = re.match(r'(.*[ *])\(?\*?([a-zA-Z0-9$_]*)\)?', text)
             # there may not be a match, say in the special case
             # where an arg is '...'
             if match:
@@ -237,13 +237,13 @@ class Function:
         self.date = datetime.date.today().year
 
         function, comments = line.split(';')
-        comment = re.search('/\* *(.*) *\*/', comments)
+        comment = re.search(r'/\* *(.*) *\*/', comments)
         if comment:
             self.comments = comment.group(1)
         else:
             self.comments = None
 
-        bits = re.match('([^(]*)\((.*)\)', function)
+        bits = re.match(r'([^(]*)\((.*)\)', function)
         type_and_name = Argument(bits.group(1))
         self.type, self.name = type_and_name.type, type_and_name.name
         # convenient to have this declared here so we can use its .decl 

later

Signature · 1 line
2.45.0