]> granicus.if.org Git - python/commitdiff
Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD.
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 21 Nov 2014 19:55:39 +0000 (21:55 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 21 Nov 2014 19:55:39 +0000 (21:55 +0200)
Lib/uuid.py

index 83210134903401cfd8e8904f9da763fb28db153e..1061bffc43c7184f4d280b9c5d4b2d557190811b 100644 (file)
@@ -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)