changeset: 93530:301d62ef5c0b branch: 2.7 parent: 93527:c9b4dc1ab7ae user: Serhiy Storchaka date: Fri Nov 21 21:54:43 2014 +0200 files: Lib/uuid.py description: Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD. diff -r c9b4dc1ab7ae -r 301d62ef5c0b Lib/uuid.py --- a/Lib/uuid.py Fri Nov 21 02:05:06 2014 +0100 +++ b/Lib/uuid.py Fri Nov 21 21:54:43 2014 +0200 @@ -345,7 +345,10 @@ 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)