From 138ec8c1186e6306a2e526a3d3c4a3c92da4486e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 21 Nov 2014 21:54:43 +0200 Subject: [PATCH] Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD. --- Lib/uuid.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/uuid.py b/Lib/uuid.py index f22536003b2..0f0d8c15de0 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -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)