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: