--- test_fileinput.py.orig 2015-11-01 22:47:30.193112793 +0900 +++ test_fileinput.py 2015-11-01 22:54:39.461124614 +0900 @@ -289,6 +289,19 @@ # Read to the end of file. list(fi) + def test_readline_binary_mode(self): + with open(TESTFN, 'wb') as f: + f.write(b'A\nB\r\nC\r') + self.addCleanup(safe_unlink, TESTFN) + + with FileInput(files=TESTFN, mode='rb') as fi: + self.assertEqual(fi.readline(), b'A\n') + self.assertEqual(fi.readline(), b'B\r\n') + self.assertEqual(fi.readline(), b'C\r') + # Read to the end of file. + self.assertEqual(fi.readline(), b'') + self.assertEqual(fi.readline(), b'') + def test_context_manager(self): try: t1 = writeTmp(1, ["A\nB\nC"])