Skip to content

Commit c4abb00

Browse files
author
git apple-llvm automerger
committed
Merge commit '9bec2621ba37' from llvm.org/main into next
2 parents 92a19ed + 9bec262 commit c4abb00

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Changes to the LLVM tools
152152
---------------------------------
153153

154154
* `llvm-readelf` now dumps all hex format values in lower-case mode.
155+
* Some code paths for supporting Python 2.7 in `llvm-lit` have been removed.
155156

156157
Changes to LLDB
157158
---------------------------------

llvm/utils/lit/lit/builtin_commands/diff.py

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,15 @@ def compareTwoFiles(flags, filepaths):
5959

6060
def compareTwoBinaryFiles(flags, filepaths, filelines):
6161
exitCode = 0
62-
if hasattr(difflib, "diff_bytes"):
63-
# python 3.5 or newer
64-
diffs = difflib.diff_bytes(
65-
difflib.unified_diff,
66-
filelines[0],
67-
filelines[1],
68-
filepaths[0].encode(),
69-
filepaths[1].encode(),
70-
n=flags.num_context_lines,
71-
)
72-
diffs = [diff.decode(errors="backslashreplace") for diff in diffs]
73-
else:
74-
# python 2.7
75-
if flags.unified_diff:
76-
func = difflib.unified_diff
77-
else:
78-
func = difflib.context_diff
79-
diffs = func(
80-
filelines[0],
81-
filelines[1],
82-
filepaths[0],
83-
filepaths[1],
84-
n=flags.num_context_lines,
85-
)
62+
diffs = difflib.diff_bytes(
63+
difflib.unified_diff,
64+
filelines[0],
65+
filelines[1],
66+
filepaths[0].encode(),
67+
filepaths[1].encode(),
68+
n=flags.num_context_lines,
69+
)
70+
diffs = [diff.decode(errors="backslashreplace") for diff in diffs]
8671

8772
for diff in diffs:
8873
sys.stdout.write(to_string(diff))
@@ -230,14 +215,8 @@ def compareDirTrees(flags, dir_trees, base_paths=["", ""]):
230215

231216
def main(argv):
232217
if sys.platform == "win32":
233-
if hasattr(sys.stdout, "buffer"):
234-
# python 3
235-
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, newline="\n")
236-
else:
237-
# python 2.7
238-
import msvcrt
218+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, newline="\n")
239219

240-
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
241220
args = argv[1:]
242221
try:
243222
opts, args = getopt.gnu_getopt(args, "wbuI:U:r", ["strip-trailing-cr"])

0 commit comments

Comments
 (0)