summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-21 21:54:43 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-21 21:54:43 +0200
commit081db9f98790fda3223921ffdc6a9a901d7fc505 (patch)
treecb4abb4b84fd18755b99266172ac6582e5944446
parentacdd636f03ed81759969e1306c0e803231ae2106 (diff)
downloadcpython-081db9f98790fda3223921ffdc6a9a901d7fc505.tar.gz
Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD.
-rw-r--r--Lib/uuid.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index f22536003b..0f0d8c15de 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)