Skip to content

Commit 6095ae4

Browse files
committed
Fix syntax warnings with Python 3.12
Python 3.12 introduced a SyntaxWarning for invalid escape sequences in string literals. Use raw string literals where strings with backslash characters are required. Signed-off-by: Ingo van Lil <[email protected]>
1 parent cb99eb2 commit 6095ae4

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/redfish/discovery/discovery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def discover_ssdp(port=1900, ttl=2, response_time=3, iface=None, protocol="ipv4"
9999
# On the same socket, wait for responses
100100
discovered_services = {}
101101
pattern = re.compile(
102-
"^uuid:([a-f0-9\-]*)::urn:dmtf-org:service:redfish-rest:1(:\d+)?$") # noqa
102+
r"^uuid:([a-f0-9\-]*)::urn:dmtf-org:service:redfish-rest:1(:\d+)?$") # noqa
103103
while True:
104104
try:
105105
response = http.client.HTTPResponse(FakeSocket(sock.recv(1024)))

src/redfish/messages/messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def search_message(response, message_registry_group, message_registry_id):
104104
else:
105105
messages_detail = get_messages_detail(response)
106106

107-
message_registry_id_search = "^" + message_registry_group + "\.[0-9]+\.[0-9]+\." + message_registry_id +"$"
107+
message_registry_id_search = "^" + message_registry_group + r"\.[0-9]+\.[0-9]+\." + message_registry_id +"$"
108108

109109
for messages_item in messages_detail["@Message.ExtendedInfo"]:
110110
if "MessageId" in messages_item:

src/redfish/rest/v1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ def _rest_request(self, path, method='GET', args=None, body=None,
886886
if restreq.body[0] == '{':
887887
# Mask password properties
888888
# NOTE: If the password itself contains a double quote, it will not redact the entire password
889-
logbody = re.sub('"Password"\s*:\s*".*?"', '"Password": "<REDACTED>"', restreq.body)
889+
logbody = re.sub(r'"Password"\s*:\s*".*?"', '"Password": "<REDACTED>"', restreq.body)
890890
else:
891891
raise ValueError('Body of message is binary')
892892
LOGGER.debug('HTTP REQUEST (%s) for %s:\nHeaders:\n%s\nBody: %s\n'% \

0 commit comments

Comments
 (0)