From d953d83773af24341f961f3c003433b8a5006810 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 10 Jan 2017 10:36:06 +0100 Subject: [PATCH] mitmdump: fix reading from stdin --- mitmproxy/master.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mitmproxy/master.py b/mitmproxy/master.py index 7581d8164..ee240eeb7 100644 --- a/mitmproxy/master.py +++ b/mitmproxy/master.py @@ -170,8 +170,11 @@ class Master: path = os.path.expanduser(path) try: if path == "-": - # This is incompatible with Python 3 - maybe we can use click? - freader = io.FlowReader(sys.stdin) + try: + sys.stdin.buffer.read(0) + except Exception as e: + raise IOError("Cannot read from stdin: {}".format(e)) + freader = io.FlowReader(sys.stdin.buffer) return self.load_flows(freader) else: with open(path, "rb") as f: