Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD.

This commit is contained in:
Serhiy Storchaka 2014-11-21 21:54:43 +02:00
parent fc419fbc71
commit 138ec8c118
1 changed files with 4 additions and 1 deletions

View File

@ -345,7 +345,10 @@ def _ifconfig_getnode():
def _arp_getnode():
"""Get the hardware address on Unix by running arp."""
import os, socket
ip_addr = socket.gethostbyname(socket.gethostname())
try:
ip_addr = socket.gethostbyname(socket.gethostname())
except EnvironmentError:
return None
# Try getting the MAC addr from arp based on our IP address (Solaris).
return _find_mac('arp', '-an', [ip_addr], lambda i: -1)