aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/platform
diff options
context:
space:
mode:
authorstrohu <strohu@users.noreply.github.com>2016-07-12 15:47:01 +0100
committerGitHub <noreply@github.com>2016-07-12 15:47:01 +0100
commit6a9407d7cc4ac5555180a2ee331ff95eef131902 (patch)
tree7d6a0b48e9c7a3dace41e23c507e7055f5ca29a3 /mitmproxy/platform
parent4fd71d7bfdb3d0568262be807eed1268441df9e9 (diff)
downloadmitmproxy-6a9407d7cc4ac5555180a2ee331ff95eef131902.tar.gz
mitmproxy-6a9407d7cc4ac5555180a2ee331ff95eef131902.tar.bz2
mitmproxy-6a9407d7cc4ac5555180a2ee331ff95eef131902.zip
Make sudo pfctl error check Python 3 compatible
In Python 3, subprocess.check_output() returns a sequence of bytes. This change ensures that it will be converted to a string, so the substring test for the sudo error message does not raise a TypeError. This fixes the code in Python 3 while remaining compatible with Python 2.
Diffstat (limited to 'mitmproxy/platform')
-rw-r--r--mitmproxy/platform/osx.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mitmproxy/platform/osx.py b/mitmproxy/platform/osx.py
index b5dce793..6a555f32 100644
--- a/mitmproxy/platform/osx.py
+++ b/mitmproxy/platform/osx.py
@@ -23,12 +23,12 @@ class Resolver(object):
try:
stxt = subprocess.check_output(self.STATECMD, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
- if "sudo: a password is required" in e.output:
+ if "sudo: a password is required" in e.output.decode(errors="replace"):
insufficient_priv = True
else:
raise RuntimeError("Error getting pfctl state: " + repr(e))
else:
- insufficient_priv = "sudo: a password is required" in stxt
+ insufficient_priv = "sudo: a password is required" in stxt.decode(errors="replace")
if insufficient_priv:
raise RuntimeError(