зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
34942c95ff
Коммит
056d0d693c
|
@ -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)]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче