diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2024-05-02 02:22:17 +0200 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2024-05-02 13:03:44 +0200 |
commit | b15d2af6ed534c550a546493b5ff4c43d898e5f2 (patch) | |
tree | 03552348be44b5ff1fcb244ef4f13eb516c85809 /osmopy/osmo_interact | |
parent | 92014a44fd038be1a9cbc1526fc4ecbc983ddd18 (diff) |
fix "SyntaxWarning: invalid escape sequence '\('"
This is a new warning introduced in Python 3.12:
https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
Python 3 interprets string literals as Unicode strings, and so '\('
is treated as an escaped Unicode character. Fix this by prefixing
the regexp strings with 'r' and thus converting them to raw strings.
Change-Id: I7a9f546dc7cdf9bc250516a58f35b50b46017dc3
Diffstat (limited to 'osmopy/osmo_interact')
-rwxr-xr-x | osmopy/osmo_interact/ctrl.py | 2 | ||||
-rwxr-xr-x | osmopy/osmo_interact/vty.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/osmopy/osmo_interact/ctrl.py b/osmopy/osmo_interact/ctrl.py index 85e7554..375920b 100755 --- a/osmopy/osmo_interact/ctrl.py +++ b/osmopy/osmo_interact/ctrl.py @@ -32,7 +32,7 @@ from osmopy.osmo_ipa import Ctrl, IPA class InteractCtrl(Interact): next_id = 1 keep_ids = True - re_command = re.compile('^(SET|GET) ([^ ]*) (.*)$') + re_command = re.compile(r'^(SET|GET) ([^ ]*) (.*)$') class CtrlStep(Interact.StepBase): diff --git a/osmopy/osmo_interact/vty.py b/osmopy/osmo_interact/vty.py index 1cc299c..851b0eb 100755 --- a/osmopy/osmo_interact/vty.py +++ b/osmopy/osmo_interact/vty.py @@ -95,7 +95,7 @@ class InteractVty(Interact): if not self.prompt: raise Exception('Could not find application name; needed to decode prompts.' ' Initial data was: %r' % data) - self.re_prompt = re.compile('^%s(?:\(([\w-]*)\))?([#>]) (.*)$' % re.escape(self.prompt)) + self.re_prompt = re.compile(r'^%s(?:\(([\w-]*)\))?([#>]) (.*)$' % re.escape(self.prompt)) def _command(self, command_str, timeout=10): self.socket.send(command_str.encode()) |