Skip to content

Fix SyntaxWarning in regex pattern string#138

Merged
alexanderjordanbaker merged 1 commit into
apple:mainfrom
krepe90:main
Jun 12, 2025
Merged

Fix SyntaxWarning in regex pattern string#138
alexanderjordanbaker merged 1 commit into
apple:mainfrom
krepe90:main

Conversation

@krepe90
Copy link
Copy Markdown
Contributor

@krepe90 krepe90 commented May 15, 2025

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

In Python 3.12, invalid escape sequence (such as `\s`) in normal string emits SyntaxWarning.
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
Copy link
Copy Markdown
Collaborator

@alexanderjordanbaker alexanderjordanbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@alexanderjordanbaker alexanderjordanbaker merged commit 96199a2 into apple:main Jun 12, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants