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

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 13 06:06:26 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Jie Fu (傅杰) (DamonFool)

<details>
<summary>Changes</summary>

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
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")

``````````

</details>


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


More information about the cfe-commits mailing list