From: Serhiy Storchaka Date: Fri, 21 Nov 2014 19:55:39 +0000 (+0200) Subject: Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD. X-Git-Tag: v3.4.3rc1~319 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=525d5aeaaef40ad254da57a93b35a07ecb2bdb0b;p=thirdparty%2FPython%2Fcpython.git Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD. --- diff --git a/Lib/uuid.py b/Lib/uuid.py index 832101349034..1061bffc43c7 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -361,7 +361,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 OSError: + 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)