Skip to content

Commit b1d1c33

Browse files
authored
[lit] Remove legacy python version checks (NFC) (#105948)
1 parent d2b420c commit b1d1c33

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

llvm/utils/lit/lit/TestRunner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@ def maybeUnescape(arg):
406406
return arg
407407

408408
arg = lit.util.to_bytes(arg)
409-
codec = "string_escape" if sys.version_info < (3, 0) else "unicode_escape"
410-
return arg.decode(codec)
409+
return arg.decode("unicode_escape")
411410

412411
if args:
413412
for arg in args[:-1]:
@@ -1173,7 +1172,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
11731172
open_kwargs = {}
11741173
if litConfig.isWindows and not isWin32CMDEXE:
11751174
mode += "b" # Avoid CRLFs when writing bash scripts.
1176-
elif sys.version_info > (3, 0):
1175+
else:
11771176
open_kwargs["encoding"] = "utf-8"
11781177
f = open(script, mode, **open_kwargs)
11791178
if isWin32CMDEXE:
@@ -1237,7 +1236,7 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
12371236
)
12381237
f.write(bytes(env_str, "utf-8") if mode == "wb" else env_str)
12391238
f.write(b"set -x;" if mode == "wb" else "set -x;")
1240-
if sys.version_info > (3, 0) and mode == "wb":
1239+
if mode == "wb":
12411240
f.write(bytes("{ " + "; } &&\n{ ".join(commands) + "; }", "utf-8"))
12421241
else:
12431242
f.write("{ " + "; } &&\n{ ".join(commands) + "; }")

llvm/utils/lit/lit/llvm/config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,7 @@ def __init__(self, lit_config, config):
186186

187187
def _find_git_windows_unix_tools(self, tools_needed):
188188
assert sys.platform == "win32"
189-
if sys.version_info.major >= 3:
190-
import winreg
191-
else:
192-
import _winreg as winreg
189+
import winreg
193190

194191
# Search both the 64 and 32-bit hives, as well as HKLM + HKCU
195192
masks = [0, winreg.KEY_WOW64_64KEY]

0 commit comments

Comments
 (0)