Merge ~calvinmwadime/ubuntu-release-upgrader:fix_invalid_escape_sequence into ubuntu-release-upgrader:ubuntu/main

Proposed by Calvin Mwadime Makokha
Status: Merged
Merged at revision: a02cf1c450739438b8600ee876892c16ef9615c5
Proposed branch: ~calvinmwadime/ubuntu-release-upgrader:fix_invalid_escape_sequence
Merge into: ubuntu-release-upgrader:ubuntu/main
Diff against target: 87 lines (+10/-10)
2 files modified
DistUpgrade/DistUpgradeGettext.py (+2/-2)
DistUpgrade/DistUpgradeQuirks.py (+8/-8)
Reviewer Review Type Date Requested Status
Nick Rosbrook Approve
Ubuntu Core Development Team Pending
Review via email: mp+463497@code.launchpad.net

Commit message

fix(regex): fix invalid escape sequence error
Python 3.12 raises an SyntaxWarning about the invalid escape sequence when installing the package.

To post a comment you must log in.
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

Thanks Calvin, for picking up the issue.

Looks good to me.

Yet, I would prefer changing all invocations of re.search() in DistUpgrade/DistUpgradeQuirks.py to use raw strings to be consistent.

Best regards

Heinrich

Revision history for this message
Calvin Mwadime Makokha (calvinmwadime) wrote :

@xypron, thanks. I have updated it.

Revision history for this message
Nick Rosbrook (enr0n) wrote :

Thanks! I built the package and installed it on noble, and the warnings are gone now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/DistUpgrade/DistUpgradeGettext.py b/DistUpgrade/DistUpgradeGettext.py
2index 35ea8cc..e6ecd38 100644
3--- a/DistUpgrade/DistUpgradeGettext.py
4+++ b/DistUpgrade/DistUpgradeGettext.py
5@@ -30,8 +30,8 @@ def _verify(message, translated):
6 helper that verifies that the message and the translated
7 message have the same number (and type) of % args
8 """
9- arguments_in_message = message.count("%") - message.count("\%")
10- arguments_in_translation = translated.count("%") - translated.count("\%")
11+ arguments_in_message = message.count(r"%") - message.count(r"\%")
12+ arguments_in_translation = translated.count(r"%") - translated.count(r"\%")
13 return arguments_in_message == arguments_in_translation
14
15
16diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
17index 6c98d29..9d7890a 100644
18--- a/DistUpgrade/DistUpgradeQuirks.py
19+++ b/DistUpgrade/DistUpgradeQuirks.py
20@@ -399,7 +399,7 @@ class DistUpgradeQuirks(object):
21 with open("/proc/cpuinfo") as f:
22 cpuinfo = f.read()
23
24- if re.search("^cpu\s*:\s*POWER8", cpuinfo, re.MULTILINE):
25+ if re.search(r"^cpu\s*:\s*POWER8", cpuinfo, re.MULTILINE):
26 logging.error("POWER8 processor detected")
27 summary = _("Sorry, no more upgrades for this system")
28 msg = _("There will not be any further Ubuntu releases "
29@@ -447,7 +447,7 @@ class DistUpgradeQuirks(object):
30 "ros-environment",
31 "ros-workspace"):
32 ros_package_patterns.add(
33- re.compile("ros-[^\-]+-%s" % package_name))
34+ re.compile(r"ros-[^\-]+-%s" % package_name))
35
36 ros_is_installed = False
37 for pkg in cache:
38@@ -556,7 +556,7 @@ class DistUpgradeQuirks(object):
39 return False
40 with open("/proc/cpuinfo") as f:
41 cpuinfo = f.read()
42- if re.search("^Processor\s*:\s*ARMv[45]", cpuinfo,
43+ if re.search(r"^Processor\s*:\s*ARMv[45]", cpuinfo,
44 re.MULTILINE):
45 return False
46 return True
47@@ -641,11 +641,11 @@ class DistUpgradeQuirks(object):
48 connected = Popen(["snap", "debug", "connectivity"], stdout=PIPE,
49 stderr=PIPE, env=snap_env,
50 universal_newlines=True).communicate()
51- if re.search("^ \* PASS", connected[0], re.MULTILINE):
52+ if re.search(r"^ \* PASS", connected[0], re.MULTILINE):
53 self._snapstore_reachable = True
54 return
55 # can't connect
56- elif re.search("^ \*.*unreachable", connected[0], re.MULTILINE):
57+ elif re.search(r"^ \*.*unreachable", connected[0], re.MULTILINE):
58 logging.error("No snap store connectivity")
59 old_lxd_deb_installed = False
60 cache = self.controller.cache
61@@ -779,7 +779,7 @@ class DistUpgradeQuirks(object):
62 pae = 0
63 with open('/proc/cpuinfo') as f:
64 cpuinfo = f.read()
65- if re.search("^flags\s+:.* pae ", cpuinfo, re.MULTILINE):
66+ if re.search(r"^flags\s+:.* pae ", cpuinfo, re.MULTILINE):
67 pae = 1
68 if not pae:
69 logging.error("no pae in /proc/cpuinfo")
70@@ -1201,7 +1201,7 @@ class DistUpgradeQuirks(object):
71 universal_newlines=True,
72 stdout=subprocess.PIPE).communicate()
73 self._view.processEvents()
74- if re.search("^installed: ", snap_info[0], re.MULTILINE):
75+ if re.search(r"^installed: ", snap_info[0], re.MULTILINE):
76 logging.debug("Snap %s is installed" % snap)
77 # its not tracking the release channel so don't switch
78 if not re.search(r"^tracking:.*%s" % from_channel,
79@@ -1235,7 +1235,7 @@ class DistUpgradeQuirks(object):
80 universal_newlines=True,
81 stdout=subprocess.PIPE).communicate()
82 self._view.processEvents()
83- if re.search("^installed: ", snap_info[0], re.MULTILINE):
84+ if re.search(r"^installed: ", snap_info[0], re.MULTILINE):
85 logging.debug("Snap %s is installed" % snap)
86 # its not tracking the release channel so don't remove
87 if not re.search(r"^tracking:.*%s" % from_channel,

Subscribers

People subscribed via source and target branches