fixeria submitted this change.
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
---
M osmopy/obscvty.py
M osmopy/osmo_interact/ctrl.py
M osmopy/osmo_interact/vty.py
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py
index 6b7d56c..5789f98 100755
--- a/osmopy/obscvty.py
+++ b/osmopy/obscvty.py
@@ -65,8 +65,8 @@
self.port = port
self.socket = None
- self.norm_end = re.compile('\r\n%s(?:\(([\w-]*)\))?> $' % self.name)
- self.priv_end = re.compile('\r\n%s(?:\(([\w-]*)\))?# $' % self.name)
+ self.norm_end = re.compile(r'\r\n%s(?:\(([\w-]*)\))?> $' % self.name)
+ self.priv_end = re.compile(r'\r\n%s(?:\(([\w-]*)\))?# $' % self.name)
self.last_node = ''
def _connect_socket(self):
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 @@
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 @@
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())
To view, visit change 36707. To unsubscribe, or for help writing mail filters, visit settings.