app-store-server-library-python
app-store-server-library-python copied to clipboard
Fix SyntaxWarning in regex pattern string
In Python 3.12, invalid escape sequence (such as \s) in normal string emits SyntaxWarning.
/Users/krepe90/github/krepe90/app-store-server-library-python/appstoreserverlibrary/receipt_utility.py:95: SyntaxWarning: invalid escape sequence '\s'
matching_result = re.search('"purchase-info"\s+=\s+"([a-zA-Z0-9+/=]+)";', decoded_top_level)
/Users/krepe90/github/krepe90/app-store-server-library-python/appstoreserverlibrary/receipt_utility.py:98: SyntaxWarning: invalid escape sequence '\s'
inner_matching_result = re.search('"transaction-id"\s+=\s+"([a-zA-Z0-9+/=]+)";', decoded_inner_level)
So I changed the regex pattern strings to use raw string literals (prefixing the string with r).
See also: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes