From: Serhiy Storchaka Date: Tue, 26 Nov 2013 20:49:36 +0000 (+0200) Subject: Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with X-Git-Tag: v3.4.0b2~462^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=822963ed5d6150f901979fe9d61ef9026e4787a5;p=thirdparty%2FPython%2Fcpython.git Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with virtual interface. Original patch by Kent Frazier. --- 822963ed5d6150f901979fe9d61ef9026e4787a5 diff --cc Lib/uuid.py index 93254ec7cf96,d5c3160fdfdf..385fb9b0876f --- a/Lib/uuid.py +++ b/Lib/uuid.py @@@ -327,9 -327,17 +327,17 @@@ def _find_mac(command, args, hw_identif words = line.lower().split() for i in range(len(words)): if words[i] in hw_identifiers: - return int( - words[get_index(i)].replace(':', ''), 16) + try: + return int( + words[get_index(i)].replace(':', ''), 16) + except (ValueError, IndexError): + # Virtual interfaces, such as those provided by + # VPNs, do not have a colon-delimited MAC address + # as expected, but a 16-byte HWAddr separated by + # dashes. These should be ignored in favor of a + # real MAC address + pass - except IOError: + except OSError: continue return None