From 056d0d693c0d4e01506841cb81401bc5f573e0aa Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Fri, 25 Sep 2020 11:40:42 +0000 Subject: [PATCH] Bug 1667288 - [moznetwork] Ensure interface names returned by _get_interface_list are strings, even on python 3; r=bc Currently on my Ubuntu laptop, when running under python 3, _get_interface_list() returns a list of (byte, string), like (b'lo', '127.0.0.1') which is both inconsistent and troublesome for name comparisons like https://searchfox.org/mozilla-central/rev/89d33e1c3b0a57a9377b4815c2f4b58d933b7c32/testing/mozbase/moznetwork/moznetwork/moznetwork.py#145. Let's return (string, string) instead, regardless of py2/3. Differential Revision: https://phabricator.services.mozilla.com/D91383 --- testing/mozbase/moznetwork/moznetwork/moznetwork.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/mozbase/moznetwork/moznetwork/moznetwork.py b/testing/mozbase/moznetwork/moznetwork/moznetwork.py index 28ebe532f46f..6f70d4c84d06 100644 --- a/testing/mozbase/moznetwork/moznetwork/moznetwork.py +++ b/testing/mozbase/moznetwork/moznetwork/moznetwork.py @@ -53,7 +53,7 @@ def _get_interface_list(): namestr = names.tobytes() else: namestr = names.tostring() - return [(namestr[i:i + 32].split(b'\0', 1)[0], + return [(six.ensure_str(namestr[i:i + 32].split(b'\0', 1)[0]), socket.inet_ntoa(namestr[i + 20:i + 24])) for i in range(0, outbytes, struct_size)]