[Python-checkins] cpython (3.4): 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/97ceab0bd6f8
changeset:   93531:97ceab0bd6f8
branch:      3.4
parent:      93522:a08c3703f844
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Fri Nov 21 21:55:39 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
@@ -361,7 +361,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 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)

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


More information about the Python-checkins mailing list