diff options
| author | Damian Johnson <atagar@torproject.org> | 2016-01-26 09:36:52 -0800 |
|---|---|---|
| committer | Damian Johnson <atagar@torproject.org> | 2016-01-26 09:36:52 -0800 |
| commit | e04f453314f015ef994f798d1418670f62003386 (patch) | |
| tree | e21fae9ac2a96bad26a31a97a045274730249618 | |
| parent | 88ecc4270799d65a64ec8d52be16297ec932b705 (diff) | |
Proc connections skipped due to incorrect file mode
toralf reports that proc connection resolution no longer works and think I see
the issue. Under python3 we read the contents as unicode but our checks all
expect bytes, causing us to skip all the lines.
| -rw-r--r-- | stem/util/proc.py | 4 | ||||
| -rw-r--r-- | test/unit/util/proc.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/stem/util/proc.py b/stem/util/proc.py index 2b16ccb9..7fdd70f2 100644 --- a/stem/util/proc.py +++ b/stem/util/proc.py @@ -393,7 +393,7 @@ def connections(pid): continue try: - with open(proc_file_path) as proc_file: + with open(proc_file_path, 'rb') as proc_file: proc_file.readline() # skip the first line for line in proc_file: @@ -458,7 +458,7 @@ def _decode_proc_address_encoding(addr, is_ipv6): grouping = ip[8 * i:8 * (i + 1)] inverted += [grouping[2 * i:2 * (i + 1)] for i in range(4)][::-1] - ip = ''.join(inverted) + ip = b''.join(inverted) ip = socket.inet_ntop(socket.AF_INET6, base64.b16decode(ip)) diff --git a/test/unit/util/proc.py b/test/unit/util/proc.py index f852820f..ee52d21e 100644 --- a/test/unit/util/proc.py +++ b/test/unit/util/proc.py @@ -220,7 +220,7 @@ class TestProc(unittest.TestCase): '/proc/net/udp6': False }[param] - open_mock.side_effect = lambda param: { + open_mock.side_effect = lambda param, mode: { '/proc/net/tcp': io.BytesIO(tcp), '/proc/net/udp': io.BytesIO(udp) }[param] @@ -262,7 +262,7 @@ class TestProc(unittest.TestCase): '/proc/net/udp6': False }[param] - open_mock.side_effect = lambda param: { + open_mock.side_effect = lambda param, mode: { '/proc/net/tcp6': io.BytesIO(TCP6_CONTENT), }[param] |
