[llvm] [lit] Remove python3 version check (NFC) (PR #105948)
Keith Smiley via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 24 10:44:17 PDT 2024
https://github.com/keith updated https://github.com/llvm/llvm-project/pull/105948
>From ea5998879ab0d9aeede44f2aeda8b18feca294b0 Mon Sep 17 00:00:00 2001
From: Keith Smiley <keithbsmiley at gmail.com>
Date: Sat, 24 Aug 2024 09:12:45 -0700
Subject: [PATCH 1/2] [lit] Remove python3 version check (NFC)
---
llvm/utils/lit/lit/TestRunner.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 2d9af9fbbb3634..b56d103f718955 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1227,7 +1227,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
if test.config.pipefail:
f.write(b"set -o pipefail;" if mode == "wb" else "set -o pipefail;")
f.write(b"set -x;" if mode == "wb" else "set -x;")
- if sys.version_info > (3, 0) and mode == "wb":
+ if mode == "wb":
f.write(bytes("{ " + "; } &&\n{ ".join(commands) + "; }", "utf-8"))
else:
f.write("{ " + "; } &&\n{ ".join(commands) + "; }")
>From e272fb0af5543c66355a4ace3a79b92633e01720 Mon Sep 17 00:00:00 2001
From: Keith Smiley <keithbsmiley at gmail.com>
Date: Sat, 24 Aug 2024 10:44:05 -0700
Subject: [PATCH 2/2] more in lit
---
llvm/utils/lit/lit/TestRunner.py | 5 ++---
llvm/utils/lit/lit/llvm/config.py | 5 +----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index b56d103f718955..17a31c87ca48f4 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -406,8 +406,7 @@ def maybeUnescape(arg):
return arg
arg = lit.util.to_bytes(arg)
- codec = "string_escape" if sys.version_info < (3, 0) else "unicode_escape"
- return arg.decode(codec)
+ return arg.decode("unicode_escape")
if args:
for arg in args[:-1]:
@@ -1173,7 +1172,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
open_kwargs = {}
if litConfig.isWindows and not isWin32CMDEXE:
mode += "b" # Avoid CRLFs when writing bash scripts.
- elif sys.version_info > (3, 0):
+ else:
open_kwargs["encoding"] = "utf-8"
f = open(script, mode, **open_kwargs)
if isWin32CMDEXE:
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index b3dfddba483f53..8a6a0c2ed8089e 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -186,10 +186,7 @@ def __init__(self, lit_config, config):
def _find_git_windows_unix_tools(self, tools_needed):
assert sys.platform == "win32"
- if sys.version_info.major >= 3:
- import winreg
- else:
- import _winreg as winreg
+ import winreg
# Search both the 64 and 32-bit hives, as well as HKLM + HKCU
masks = [0, winreg.KEY_WOW64_64KEY]
More information about the llvm-commits
mailing list