]> git.ipfire.org Git - location/fedora/libloc.git/commitdiff
Fix string escaping with Python 3.12
authorPetr Písař <ppisar@redhat.com>
Mon, 24 Jul 2023 09:57:44 +0000 (11:57 +0200)
committerPetr Písař <ppisar@redhat.com>
Mon, 24 Jul 2023 10:07:13 +0000 (12:07 +0200)
libloc-0.9.16-Fix-string-escaping-in-location-tool.patch [new file with mode: 0644]
libloc.spec

diff --git a/libloc-0.9.16-Fix-string-escaping-in-location-tool.patch b/libloc-0.9.16-Fix-string-escaping-in-location-tool.patch
new file mode 100644 (file)
index 0000000..33b43c8
--- /dev/null
@@ -0,0 +1,41 @@
+From efaa883cbf89e1db6695b6cc0119eeea62256abd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
+Date: Mon, 24 Jul 2023 10:57:49 +0200
+Subject: [PATCH] Fix string escaping in location tool
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Python 3.12 started to warn on an invalid string escape sequence:
+
+$ location list-networks-by-as --format ipset 1
+/usr/bin/location:583: SyntaxWarning: invalid escape sequence '\d'
+  m = re.match("^AS(\d+)$", object)
+IpsetOutputWriter requires family being set
+
+This patch fixes the warning as well as the regular expression by
+using a raw string.
+
+<https://docs.python.org/3.12/whatsnew/changelog.html#id77>
+
+Signed-off-by: Petr Písař <ppisar@redhat.com>
+---
+ src/scripts/location.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/scripts/location.in b/src/scripts/location.in
+index 60b11d6..b34cc91 100644
+--- a/src/scripts/location.in
++++ b/src/scripts/location.in
+@@ -580,7 +580,7 @@ class CLI(object):
+                       families = [ socket.AF_INET6, socket.AF_INET ]
+               for object in ns.objects:
+-                      m = re.match("^AS(\d+)$", object)
++                      m = re.match(r"^AS(\d+)$", object)
+                       if m:
+                               object = int(m.group(1))
+-- 
+2.41.0
+
index a5f5560e8e5f5ffb1db30b14d21d19b066a81ef8..291798fc0aca2b6abbbf696f2bc02c336f31fbc8 100644 (file)
@@ -82,6 +82,9 @@ Patch0:     libloc-0.9.16-location-Fix-correct-set-name-when-family-is-selecte.p
 # 2/2 Fix "location list-networks-by-as --format ipset" output,
 # in upstream after 0.9.16, upstream bug #12897
 Patch1:     libloc-0.9.16-export-Raise-an-error-when-trying-to-export-ipset-fo.patch
+# Fix string escaping with Python 3.12, proposed to the upstream,
+# upstream bug #13188
+Patch2:     libloc-0.9.16-Fix-string-escaping-in-location-tool.patch
 BuildRequires:  asciidoc
 BuildRequires:  autoconf >= 2.60
 # autoconf-archive for unbundled m4/ax_prog_perl_modules.m4
@@ -271,6 +274,7 @@ make check %{?_smp_mflags}
 * Mon Jul 24 2023 Petr Pisar <ppisar@redhat.com> - 0.9.16-2
 - Fix "location list-networks-by-as --format ipset" output
   (upstream bug #12897)
+- Fix string escaping with Python 3.12 (upstream bug #13188)
 
 * Mon Oct 31 2022 Petr Pisar <ppisar@redhat.com> - 0.9.16-1
 - 0.9.16 bump