]> xenbits.xensource.com Git - libvirt.git/commit
python: mark regex strings with 'r' prefix
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 24 Sep 2019 12:29:27 +0000 (13:29 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Mon, 11 Nov 2019 14:24:19 +0000 (14:24 +0000)
commitd5c5d8af45e21b1ad36a0dcda66e0f32186b9780
tree2487b58dfffd53b29d41eb61b51b63505cadf837
parent524b377e9e750417d20c87670273d28c97d04a05
python: mark regex strings with 'r' prefix

When writing regexes special regex matches like "\d" can get
misinterpreted as normal string escape sequences:

docs/apibuild.py:1359:51: W605 invalid escape sequence '\d'
                        value = value + re.sub("^(\d+)U$", "\\1", token[1])
                                                  ^
docs/apibuild.py:2134:31: W605 invalid escape sequence '\('
                m = re.match("\(?1<<(\d+)\)?", info[0])
                              ^
docs/apibuild.py:2134:38: W605 invalid escape sequence '\d'
                m = re.match("\(?1<<(\d+)\)?", info[0])
                                     ^
docs/apibuild.py:2134:42: W605 invalid escape sequence '\)'
                m = re.match("\(?1<<(\d+)\)?", info[0])
                                         ^

To avoid this probem all regexes should use the r"...." syntax for their
strings, which disables normal string escape sequences.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
build-aux/syntax-check.mk
docs/apibuild.py