From: George Joseph Date: Tue, 4 Mar 2025 14:29:22 +0000 (-0700) Subject: swagger_model.py: Fix invalid escape sequence in get_list_parameter_type(). X-Git-Tag: 21.8.0-rc1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb9d8e2e467e4fb0bf008ac108f796e546a45672;p=thirdparty%2Fasterisk.git swagger_model.py: Fix invalid escape sequence in get_list_parameter_type(). 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) --- diff --git a/rest-api-templates/swagger_model.py b/rest-api-templates/swagger_model.py index cfc23a1851..0e9eba3299 100644 --- a/rest-api-templates/swagger_model.py +++ b/rest-api-templates/swagger_model.py @@ -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)