-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lit] Remove python 2.7 code paths in builtin diff #157558
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
[lit] Remove python 2.7 code paths in builtin diff #157558
Conversation
Created using spr 1.3.6 [skip ci]
Created using spr 1.3.6
@llvm/pr-subscribers-testing-tools Author: Aiden Grossman (boomanaiden154) ChangesLit's builtin diff command had some Python 2.7 code paths lying around Full diff: https://github.com/llvm/llvm-project/pull/157558.diff 1 Files Affected:
diff --git a/llvm/utils/lit/lit/builtin_commands/diff.py b/llvm/utils/lit/lit/builtin_commands/diff.py
index fbf4eb0e137b3..f2b5869b35889 100644
--- a/llvm/utils/lit/lit/builtin_commands/diff.py
+++ b/llvm/utils/lit/lit/builtin_commands/diff.py
@@ -59,30 +59,15 @@ def compareTwoFiles(flags, filepaths):
def compareTwoBinaryFiles(flags, filepaths, filelines):
exitCode = 0
- if hasattr(difflib, "diff_bytes"):
- # python 3.5 or newer
- diffs = difflib.diff_bytes(
- difflib.unified_diff,
- filelines[0],
- filelines[1],
- filepaths[0].encode(),
- filepaths[1].encode(),
- n=flags.num_context_lines,
- )
- diffs = [diff.decode(errors="backslashreplace") for diff in diffs]
- else:
- # python 2.7
- if flags.unified_diff:
- func = difflib.unified_diff
- else:
- func = difflib.context_diff
- diffs = func(
- filelines[0],
- filelines[1],
- filepaths[0],
- filepaths[1],
- n=flags.num_context_lines,
- )
+ diffs = difflib.diff_bytes(
+ difflib.unified_diff,
+ filelines[0],
+ filelines[1],
+ filepaths[0].encode(),
+ filepaths[1].encode(),
+ n=flags.num_context_lines,
+ )
+ diffs = [diff.decode(errors="backslashreplace") for diff in diffs]
for diff in diffs:
sys.stdout.write(to_string(diff))
@@ -230,14 +215,8 @@ def compareDirTrees(flags, dir_trees, base_paths=["", ""]):
def main(argv):
if sys.platform == "win32":
- if hasattr(sys.stdout, "buffer"):
- # python 3
- sys.stdout = io.TextIOWrapper(sys.stdout.buffer, newline="\n")
- else:
- # python 2.7
- import msvcrt
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, newline="\n")
- msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
args = argv[1:]
try:
opts, args = getopt.gnu_getopt(args, "wbuI:U:r", ["strip-trailing-cr"])
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me, especially since it follows our written policy on version support.
Does this need any kind of release note? It's a pure dev dependency, so I'd say "no", but I could also see how a consumer would have wanted to know about it.
It doesn't hurt to add one, so I'll throw one in. |
Created using spr 1.3.6 [skip ci]
Created using spr 1.3.6
Lit's builtin diff command had some Python 2.7 code paths lying around that we can probably get rid of at this point. LLVM at this point requires Python 3.8 at minimum. Keeping lit working at a lower version is a reasonable goal, but I think we can probably drop python 2 support at this point given how long it has been deprecated and how long LLVM has supported Python 3. Reviewers: jdenny-ornl, ilovepi, petrhosek Reviewed By: ilovepi Pull Request: llvm/llvm-project#157558
Lit's builtin diff command had some Python 2.7 code paths lying around that we can probably get rid of at this point. LLVM at this point requires Python 3.8 at minimum. Keeping lit working at a lower version is a reasonable goal, but I think we can probably drop python 2 support at this point given how long it has been deprecated and how long LLVM has supported Python 3. Reviewers: jdenny-ornl, ilovepi, petrhosek Reviewed By: ilovepi Pull Request: llvm/llvm-project#157558
Lit's builtin diff command had some Python 2.7 code paths lying around
that we can probably get rid of at this point. LLVM at this point
requires Python 3.8 at minimum. Keeping lit working at a lower version
is a reasonable goal, but I think we can probably drop python 2 support
at this point given how long it has been deprecated and how long LLVM
has supported Python 3.