[Python-checkins] cpython (2.7): Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD.

serhiy.storchaka python-checkins at python.org
Fri Nov 21 21:00:08 CET 2014


https://hg.python.org/cpython/rev/301d62ef5c0b
changeset:   93530:301d62ef5c0b
branch:      2.7
parent:      93527:c9b4dc1ab7ae
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Fri Nov 21 21:54:43 2014 +0200
summary:
  Issue #17293: socket.gethostbyname() can raise an exception of FreeBSD.

files:
  Lib/uuid.py |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Lib/uuid.py b/Lib/uuid.py
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -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)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list