Skip to content

Commit bb4531e

Browse files
committed
utils.localinterfaces: Uniquify LOCAL_IPS
On my Python 3.2.3 system, I get: >>> socket.gethostbyname_ex('localhost') ('localhost', [], ['127.0.0.1', '127.0.0.1']) After de-duplicating, LOCAL_IPS[1] (if it exists) will be a non-local IP address that might be useful to a remote host (it might also be '0.0.0.0', but I'll worry about that later).
1 parent 475b1e1 commit bb4531e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

IPython/utils/localinterfaces.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import socket
2121

22+
from .data import uniq_stable
23+
2224
#-----------------------------------------------------------------------------
2325
# Code
2426
#-----------------------------------------------------------------------------
@@ -37,4 +39,6 @@
3739
# include all-interface aliases: 0.0.0.0 and ''
3840
LOCAL_IPS.extend(['0.0.0.0', ''])
3941

42+
LOCAL_IPS = uniq_stable(LOCAL_IPS)
43+
4044
LOCALHOST = LOCAL_IPS[0]

0 commit comments

Comments
 (0)