File: 0003-fix-syntax-warnings-with-python312.patch

package info (click to toggle)
ufw 0.36.2-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,824 kB
  • sloc: python: 8,731; sh: 5,950; makefile: 200
file content (74 lines) | stat: -rw-r--r-- 3,056 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Origin: 58220106da29a1530699483bebf78f7e8da8cda1
Applied-Upstream: 58220106da29a1530699483bebf78f7e8da8cda1
Description: fix: update 're' invocations for 3.12 syntax warnings

diff --git a/setup.py b/setup.py
index 11b446e..97ce5a6 100644
--- a/setup.py
+++ b/setup.py
@@ -280,7 +280,7 @@ for e in ['ip6tables', 'iptables-restore', 'ip6tables-restore']:
 if rc != 0:
     raise OSError(errno.ENOENT, "Could not find version for '%s'" % \
                   (iptables_exe))
-version = re.sub('^v', '', re.split('\s', str(out))[1])
+version = re.sub('^v', '', str(out).split()[1])
 print("Found '%s' version '%s'" % (iptables_exe, version))
 if version < "1.4":
     print("WARN: version '%s' has limited IPv6 support. See README for details." % (version), file=sys.stderr)
diff --git a/src/common.py b/src/common.py
index 9e8417c..b97cf00 100644
--- a/src/common.py
+++ b/src/common.py
@@ -221,7 +221,7 @@ class UFWRule:
                             raise UFWError(err_msg)
                     if int(ran[0]) >= int(ran[1]):
                         raise UFWError(err_msg)
-                elif re.match('^\d+$', p):
+                elif re.match(r'^\d+$', p):
                     if int(p) < 1 or int(p) > 65535:
                         raise UFWError(err_msg)
                 elif re.match(r'^\w[\w\-]+', p):
diff --git a/src/parser.py b/src/parser.py
index b979da2..e2e018f 100644
--- a/src/parser.py
+++ b/src/parser.py
@@ -228,7 +228,7 @@ class UFWCommandRule(UFWCommand):
                 except ValueError as e:
                     raise UFWError(e)
 
-                if not re.match('^\d([0-9,:]*\d+)*$', port):
+                if not re.match(r'^\d([0-9,:]*\d+)*$', port):
                     if ',' in port or ':' in port:
                         err_msg = _("Port ranges must be numeric")
                         raise UFWError(err_msg)
@@ -354,7 +354,7 @@ class UFWCommandRule(UFWCommand):
                                 rule.sapp = tmp
                             else:
                                 rule.dapp = tmp
-                        elif not re.match('^\d([0-9,:]*\d+)*$', tmp):
+                        elif not re.match(r'^\d([0-9,:]*\d+)*$', tmp):
                             if ',' in tmp or ':' in tmp:
                                 err_msg = _("Port ranges must be numeric")
                                 raise UFWError(err_msg)
diff --git a/src/util.py b/src/util.py
index 98e3c70..a02ddfb 100644
--- a/src/util.py
+++ b/src/util.py
@@ -480,7 +480,7 @@ def _valid_dotted_quads(nm, v6):
         return False
     else:
         if re.match(r'^[0-9]+\.[0-9\.]+$', nm):
-            quads = re.split('\.', nm)
+            quads = nm.split('.')
             if len(quads) != 4:
                 return False
             for q in quads:
@@ -742,7 +742,7 @@ def get_iptables_version(exe=None):
     (rc, out) = cmd([exe, '-V'])
     if rc != 0:
         raise OSError(errno.ENOENT, "Error running '%s'" % (exe))
-    tmp = re.split('\s', out)
+    tmp = out.split()
     return re.sub('^v', '', tmp[1])