Skip to content

[lit] Remove legacy python version checks (NFC) #105948

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
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1227,7 +1226,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) + "; }")
Expand Down
5 changes: 1 addition & 4 deletions llvm/utils/lit/lit/llvm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading