Commit 10ef3264 authored by Serhiy Storchaka's avatar Serhiy Storchaka

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

parent 34d3abae
...@@ -345,7 +345,10 @@ def _ifconfig_getnode(): ...@@ -345,7 +345,10 @@ def _ifconfig_getnode():
def _arp_getnode(): def _arp_getnode():
"""Get the hardware address on Unix by running arp.""" """Get the hardware address on Unix by running arp."""
import os, socket 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). # Try getting the MAC addr from arp based on our IP address (Solaris).
return _find_mac('arp', '-an', [ip_addr], lambda i: -1) return _find_mac('arp', '-an', [ip_addr], lambda i: -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment