From 946cfc3e238bbd67ff436af5fd05414bbd2e5a08 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 14 May 2014 21:08:33 +0300 Subject: Issue #21075: fileinput.FileInput now reads bytes from standard stream if binary mode is specified. Patch by Sam Kimbrel. --- Lib/fileinput.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/fileinput.py') diff --git a/Lib/fileinput.py b/Lib/fileinput.py index de2951844ae..87758ad82b3 100644 --- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -320,7 +320,10 @@ class FileInput: self._backupfilename = 0 if self._filename == '-': self._filename = '' - self._file = sys.stdin + if 'b' in self._mode: + self._file = sys.stdin.buffer + else: + self._file = sys.stdin self._isstdin = True else: if self._inplace: -- cgit v1.2.3