Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 520d8ec

Browse files
committed
fix Python 3 issue
1 parent 23f9a77 commit 520d8ec

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ghdiff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ def main(args=None, stdout=sys.stdout):
128128
sys.exit(-1)
129129

130130
def read_file(filename):
131-
with open(filename) as f:
131+
with open(filename, "rb") as f:
132132
text = f.read()
133133
codepage = chardet.detect(text)['encoding']
134134
return text.decode(codepage).splitlines()
135135

136136
a = read_file(args[0])
137137
b = read_file(args[1])
138-
six.print_(diff(a, b, css=options.css).encode('utf-8'), file=stdout)
138+
stdout.write(diff(a, b, css=options.css).encode("utf-8"))
139139

140140
if __name__ == "__main__":
141141
main(sys.argv[1:])

src/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def test_script(self):
3333
out = io.BytesIO()
3434
ghdiff.main([f1, f2], stdout=out)
3535
output = out.getvalue()
36-
self.assertTrue("-foobar" in output)
37-
self.assertTrue('+foobar<span class="highlight">baz</span>' in output)
36+
self.assertTrue(b"-foobar" in output)
37+
self.assertTrue(b'+foobar<span class="highlight">baz</span>' in output)
3838

3939
def test_no_css_option(self):
4040
"""Simple test for --no-css option"""
@@ -43,7 +43,7 @@ def test_no_css_option(self):
4343
out = io.BytesIO()
4444
ghdiff.main([f1, f2, "--no-css"], stdout=out)
4545
output = out.getvalue()
46-
self.assertFalse("<style" in output)
46+
self.assertFalse(b"<style" in output)
4747

4848

4949
def test_suite():

0 commit comments

Comments
 (0)