[llvm] [lit] Use raw strings for backslash escapes to fix SyntaxWarnings (PR #70907)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 1 00:50:23 PDT 2023
https://github.com/h-vetinari created https://github.com/llvm/llvm-project/pull/70907
Unless specified as a "raw" string, Python will try to interpret backslashes, which means they don't get passed on correctly to the underlying regex-engine, unless escaped manually (`\\`).
Use raw strings in `llvm/test/lit.cfg.py` to avoid a `SyntaxWarning`:
```
llvm/test/lit.cfg.py:275: SyntaxWarning: invalid escape sequence '\d'
match = re.search("release (\d+)\.(\d+)", ptxas_out)
```
Other such warning present in 17.0.x were already fixed in 7ed0f5b6de74989c739389770a2d45dc7d58166a.
>From a943bf960916720e8e2dfdec8d0f2ab843842d3b Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari at gmx.com>
Date: Wed, 1 Nov 2023 18:46:33 +1100
Subject: [PATCH] [lit] Use raw strings for backslash escapes to fix
SyntaxWarnings
Unless specified as a "raw" string, Python will try to interpret
backslashes, which means they don't get passed on correctly to the
underlying regex-engine, unless escaped manually (`\\`).
Use raw strings in `llvm/test/lit.cfg.py` to avoid a `SyntaxWarning`:
```
llvm/test/lit.cfg.py:275: SyntaxWarning: invalid escape sequence '\d'
match = re.search("release (\d+)\.(\d+)", ptxas_out)
```
Other such warning present in 17.0.x were already fixed in 7ed0f5b6de74989c739389770a2d45dc7d58166a.
---
llvm/test/lit.cfg.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..5f4cff424f073b8 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
ptxas_cmd.wait()
- match = re.search("release (\d+)\.(\d+)", ptxas_out)
+ match = re.search(r"release (\d+)\.(\d+)", ptxas_out)
if match:
return (int(match.group(1)), int(match.group(2)))
print("couldn't determine ptxas version")
More information about the llvm-commits
mailing list