Skip to content

[clang] SyntaxWarning: invalid escape sequence '\s' with Python3.12 #78036

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

Merged
merged 2 commits into from
Jan 14, 2024

Conversation

DamonFool
Copy link
Member

The following SyntaxWarning was observed with Python3.12 .

llvm-project/clang/tools/libclang/linker-script-to-export-list.py:9: SyntaxWarning: invalid escape sequence '\s'
  m = re.search("^\s+(clang_[^;]+)", line)

Similar problem had been reported here https://stackoverflow.com/questions/57645829/why-am-i-getting-a-syntaxwarning-invalid-escape-sequence-s-warning .

It would be better to fix it.
Thanks.

llvm-project/clang/tools/libclang/linker-script-to-export-list.py:9: SyntaxWarning: invalid escape sequence '\s'
  m = re.search("^\s+(clang_[^;]+)", line)
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 13, 2024

@llvm/pr-subscribers-clang

Author: Jie Fu (傅杰) (DamonFool)

Changes

The following SyntaxWarning was observed with Python3.12 .

llvm-project/clang/tools/libclang/linker-script-to-export-list.py:9: SyntaxWarning: invalid escape sequence '\s'
  m = re.search("^\s+(clang_[^;]+)", line)

Similar problem had been reported here https://stackoverflow.com/questions/57645829/why-am-i-getting-a-syntaxwarning-invalid-escape-sequence-s-warning .

It would be better to fix it.
Thanks.


Full diff: https://github.com/llvm/llvm-project/pull/78036.diff

1 Files Affected:

  • (modified) clang/tools/libclang/linker-script-to-export-list.py (+1-1)
diff --git a/clang/tools/libclang/linker-script-to-export-list.py b/clang/tools/libclang/linker-script-to-export-list.py
index 745996028d835f..35bfa230be704a 100644
--- a/clang/tools/libclang/linker-script-to-export-list.py
+++ b/clang/tools/libclang/linker-script-to-export-list.py
@@ -6,6 +6,6 @@
 output_file = open(sys.argv[2], "w")
 
 for line in input_file:
-    m = re.search("^\s+(clang_[^;]+)", line)
+    m = re.search("^\\s+(clang_[^;]+)", line)
     if m:
         output_file.write(m.group(1) + "\n")

@DamonFool DamonFool self-assigned this Jan 13, 2024
@DamonFool DamonFool merged commit 7851670 into llvm:main Jan 14, 2024
@DamonFool
Copy link
Member Author

Thanks @MaskRay and @cor3ntin for the review.

@DamonFool DamonFool deleted the jf-SyntaxWarning branch January 14, 2024 10:15
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…lvm#78036)

llvm-project/clang/tools/libclang/linker-script-to-export-list.py:9: SyntaxWarning: invalid escape sequence '\s'
  m = re.search("^\s+(clang_[^;]+)", line)

Co-authored-by: cor3ntin <[email protected]>
lukel97 added a commit to lukel97/llvm-project that referenced this pull request Feb 20, 2024
On Python 3.12 we now get a warning in common.py:

llvm/utils/UpdateTestChecks/common.py:488: SyntaxWarning: invalid escape sequence '\s'

This fixes it by using a raw string literal, see
llvm#78036 and
https://docs.python.org/3/library/re.html
lukel97 added a commit that referenced this pull request Feb 20, 2024
On Python 3.12 we now get a warning in common.py:

llvm/utils/UpdateTestChecks/common.py:488: SyntaxWarning: invalid escape
sequence '\s'

This fixes it by using a raw string literal, see
#78036 and
https://docs.python.org/3/library/re.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants