Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fedora support + remove build warnings #763

Merged
merged 2 commits into from
Mar 3, 2024

Conversation

Victor333Huesca
Copy link

Add support for Fedora 39 (tested under WSL).

Use raw literal in python regex strings, this is the right way to escape regex's special characters in python.
Otherwise, python first tries to escape the characters itself, fails and issue a warning which is confusing to user.

Checklist

  • Referenced all related issues in the PR body (e.g. "Closes #xyz")
  • Have tested the modifications

This removes warning about invalid escapes.
Also drop unicode literals (ignored in python 3), since we don't support python 2.
@Howard20181 Howard20181 merged commit 3014fc9 into LSPosed:main Mar 3, 2024
2 checks passed
@Victor333Huesca
Copy link
Author

Hi,
Thanks for the review!
I notice you did forced-pushed 2 commits after, thus dropping this merge.
Was it intentional, is there a bug with this patch?

@Howard20181
Copy link
Member

In some python scripts wrong use of raw strings may break escape characters

@Victor333Huesca
Copy link
Author

Victor333Huesca commented Mar 5, 2024

According to the official python documentation: https://docs.python.org/3/library/re.html

Regular expressions use the backslash character ('') to indicate special forms or to allow special characters to be used without invoking their special meaning. This collides with Python’s usage of the same character for the same purpose in string literals; for example, to match a literal backslash, one might have to write '\\' as the pattern string, because the regular expression must be \, and each backslash must be expressed as \ inside a regular Python string literal. Also, please note that any invalid escape sequences in Python’s usage of the backslash in string literals now generate a SyntaxWarning and in the future this will become a SyntaxError. This behaviour will happen even if it is a valid escape sequence for a regular expression.

The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'. So r"\n" is a two-character string containing '' and 'n', while "\n" is a one-character string containing a newline. Usually patterns will be expressed in Python code using this raw string notation.

So I believe this is more likely to avoid SyntaxWarning or SyntaxError in the future.

If you feel like you prefer to do more testing or discard it completely but still want to benefit from the Fedora support, let me know, so I can separate this into two pull requests (or only keep the fedora patch, as you prefer).

@Howard20181
Copy link
Member

When you use raw string, you should remove \ from strings.

You can make changes to *.sh to make Fedora support. Don't commit unrelated changes to the same pull request

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