]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
swagger_model.py: Fix invalid escape sequence in get_list_parameter_type().
authorGeorge Joseph <gjoseph@sangoma.com>
Tue, 4 Mar 2025 14:29:22 +0000 (07:29 -0700)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 20 Mar 2025 18:29:21 +0000 (18:29 +0000)
Recent python versions complain when backslashes in strings create invalid
escape sequences.  This causes issues for strings used as regex patterns like
`'^List\[(.*)\]$'` where you want the regex parser to treat `[` and `]`
as literals.  Double-backslashing is one way to fix it but simply converting
the string to a raw string `re.match(r'^List\[(.*)\]$', text)` is easier
and less error prone.

(cherry picked from commit f80e2405e64c32898380230c5f5bf38c168814e5)

rest-api-templates/swagger_model.py

index cfc23a18515b2aff092893a38aca5621d07ef9dc..0e9eba329955e08cd1072e936dd23c4e6139351e 100644 (file)
@@ -464,7 +464,7 @@ def get_list_parameter_type(type_string):
     @param type_string: Type string to parse
     @returns Type parameter of the list, or None if not a List.
     """
-    list_match = re.match('^List\[(.*)\]$', type_string)
+    list_match = re.match(r'^List\[(.*)\]$', type_string)
     return list_match and list_match.group(1)