[master] 70e87cda7 Minor r'str' fix to vmodtool.py
Nils Goroll
nils.goroll at uplex.de
Mon Sep 16 13:22:04 UTC 2024
commit 70e87cda78d14f9b03662afe1766d0d9ed77d79b
Author: Yuri Astrakhan <YuriAstrakhan at gmail.com>
Date: Fri Sep 13 14:44:05 2024 -0400
Minor r'str' fix to vmodtool.py
Python does not like having `\` characters followed by non-special characters, e.g. `\.` - but regex requires that. For this, python has "raw strings", e.g. `r'....'` - this way no `\` have any special meaning to python, only to the regex itself. At least on my 3.12 Python it refused to work without it.
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 2d3d94640..21d91a7b4 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -342,11 +342,11 @@ class ProtoType():
self.retval = CType(['VOID'], st.vcc.enums)
self.bname = wl.pop(0)
- if not re.match("^[a-zA-Z.][a-zA-Z0-9_]*$", self.bname):
+ if not re.match(r'^[a-zA-Z.][a-zA-Z0-9_]*$', self.bname):
err("%s(): Illegal name\n" % self.bname, warn=False)
self.name = prefix + self.bname
- if not re.match('^[a-zA-Z_][a-zA-Z0-9_]*$', self.cname()):
+ if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', self.cname()):
err("%s(): Illegal C-name\n" % self.cname(), warn=False)
if len(wl) == 2 and wl[0] == '(' and wl[1] == ')':
@@ -899,10 +899,10 @@ class AliasStanza(Stanza):
def parse(self):
if len(self.toks) != 3:
err("Syntax error, expected: $Alias <alias> <symbol>\n", warn=False)
- if not re.match('^\.?[a-zA-Z_][a-zA-Z0-9_]*$', self.toks[1]):
+ if not re.match(r'^\.?[a-zA-Z_][a-zA-Z0-9_]*$', self.toks[1]):
err("%s(): Illegal C-name\n" % self.toks[1], warn=False)
if self.toks[1][0] == '.':
- if not re.match('^[a-zA-Z_][a-zA-Z0-9_]*\.[a-zA-Z_][a-zA-Z0-9_]*$',
+ if not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*\.[a-zA-Z_][a-zA-Z0-9_]*$',
self.toks[2]):
err("Syntax error, expected: $Alias <.alias> <obj.method>\n",
warn=False)
More information about the varnish-commit
mailing list