[S] Change in ...osmo-python-tests[master]: fix "SyntaxWarning: invalid escape sequence '\('"
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/36707?usp=email ) Change subject: fix "SyntaxWarning: invalid escape sequence '\('" ...................................................................... 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(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/07/36707/1 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 https://gerrit.osmocom.org/c/python/osmo-python-tests/+/36707?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: I7a9f546dc7cdf9bc250516a58f35b50b46017dc3 Gerrit-Change-Number: 36707 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
fixeria