Skip to content
Snippets Groups Projects
Commit e04f4533 authored by Damian Johnson's avatar Damian Johnson
Browse files

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.
parent 88ecc427
Branches
Tags
No related merge requests found
......@@ -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))
......
......@@ -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]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment