Skip to content

Commit bd3dffb

Browse files
committed
Fix difflib.context_diff for Python 3.14 compatibility
Python 3.14's difflib.context_diff expects sequences of strings (lists of lines), not strings directly. Split strings into lines using splitlines(keepends=True) before passing to context_diff. Fixes TypeError in test_utils.assert_equal() on Python 3.14.
1 parent e40c3fa commit bd3dffb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/test_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def assert_equal(expected: bytes, actual: bytes):
2626
expected_str = expected.decode()
2727
actual_str = actual.decode()
2828
print("String comparison:", expected_str == actual_str)
29-
diff_lines_gen = difflib.context_diff(expected_str, actual_str, "Expected", "Actual")
29+
# difflib.context_diff requires sequences of strings (lines), not strings
30+
expected_lines = expected_str.splitlines(keepends=True)
31+
actual_lines = actual_str.splitlines(keepends=True)
32+
diff_lines_gen = difflib.context_diff(expected_lines, actual_lines, "Expected", "Actual")
3033
diff_lines = "".join(list(diff_lines_gen))
3134
print(f"\n\nDifference:\n{diff_lines}")
3235
else:

0 commit comments

Comments
 (0)