From 2d1e72b678e28512c9ac92cd6f7d5c0dec760f4b Mon Sep 17 00:00:00 2001 From: Thomas Mieslinger Date: Mon, 4 Aug 2025 22:03:58 +0200 Subject: [PATCH] fix regular expression syntax for python 3.13 --- dim-testsuite/runtest.py | 22 +++++++++++----------- dim-testsuite/tests/pdns_util.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dim-testsuite/runtest.py b/dim-testsuite/runtest.py index 0efe5c4f..a49f8937 100755 --- a/dim-testsuite/runtest.py +++ b/dim-testsuite/runtest.py @@ -237,22 +237,22 @@ def check_regexes(table, regexes): if re.search(b'list zone .* keys', cmd): for row in table: row[0] = re.compile(b'.*_[zk]sk_.*') - row[2] = re.compile(b'\d*') + row[2] = re.compile(rb'\d*') row[5] = re.compile(b'.*') if re.search(b'list zone .* dnskeys', cmd): for row in table: - row[0] = re.compile(b'\d*') - row[1] = re.compile(b'\d*') + row[0] = re.compile(rb'\d*') + row[1] = re.compile(rb'\d*') row[3] = re.compile(b'.*') if re.search(b'list zone .* keys', cmd): for row in table: row[0] = re.compile(b'.*') - row[2] = re.compile(b'\d*') + row[2] = re.compile(rb'\d*') row[5] = re.compile(b'.*') if re.search(b'list zone .* ds', cmd): for row in table[1:]: - row[0] = re.compile(b'\d*') - row[2] = re.compile(b'\d') + row[0] = re.compile(rb'\d*') + row[2] = re.compile(rb'\d') row[3] = re.compile(b'.*') if b'dcli list zone' in cmd or b'dcli dump zone' in cmd or b'dcli list rrs' in cmd: for rr_row in table: @@ -260,22 +260,22 @@ def check_regexes(table, regexes): if (rr_col + 1) < len(rr_row): if rr_row[rr_col] == b'SOA': stuff = rr_row[rr_col + 1].split() - rr_row[rr_col + 1] = re.compile(b'%s %s \d+ \d+ \d+ \d+ \d+' % (stuff[0], stuff[1])) + rr_row[rr_col + 1] = re.compile(rb'%s %s \d+ \d+ \d+ \d+ \d+' % (stuff[0], stuff[1])) elif rr_row[rr_col] == b'DS': - rr_row[rr_col + 1] = re.compile(b'\d+ 8 2 .*') + rr_row[rr_col + 1] = re.compile(rb'\d+ 8 2 .*') elif b'dcli history' in cmd: for row in table: if row[0] != b'timestamp': row[0] = re.compile(b'.*') if row[-1].startswith(b'set_attr serial='): - row[-1] = re.compile(b'set_attr serial=\d+') + row[-1] = re.compile(rb'set_attr serial=\d+') if row[4] == b'key': row[5] = re.compile(b'.*') elif b'dnssec enable' in cmd or b'dnssec new' in cmd: check_regexes(table, [b'.*Created key .*_[zk]sk_.* for zone (.*)', - b'.*Creating RR .* DS \d+ 8 2 .* in zone .*']) + rb'.*Creating RR .* DS \d+ 8 2 .* in zone .*']) elif b'dnssec disable' in cmd or b'dnssec delete' in cmd or b'delete zone' in cmd: - check_regexes(table, [b'.*Deleting RR .* DS \d+ 8 2 .* from zone .*']) + check_regexes(table, [rb'.*Deleting RR .* DS \d+ 8 2 .* from zone .*']) return table diff --git a/dim-testsuite/tests/pdns_util.py b/dim-testsuite/tests/pdns_util.py index 37d87653..7780ccb3 100644 --- a/dim-testsuite/tests/pdns_util.py +++ b/dim-testsuite/tests/pdns_util.py @@ -35,7 +35,7 @@ def zones_equal(a, b): '''Ignores differences in whitespace even inside strings''' ac = compact(a) bc = compact(b) - if len(ac) != len(bc) or any(re.sub('\s+', '', l1) != re.sub('\s+', '', l2) + if len(ac) != len(bc) or any(re.sub(r'\s+', '', l1) != re.sub(r'\s+', '', l2) for l1, l2 in zip(ac, bc)): pdns_file = '/tmp/pdns.zone' dim_file = '/tmp/dim.zone'