diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-26 20:47:16 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-11-26 20:47:16 (GMT) |
commit | 56507c7862b6e2de189b6a942f394efb676cdb0b (patch) | |
tree | 5f81a187f15ef5c7c7f8810cbf8328b98cce432f /Lib/uuid.py | |
parent | a04f4e0374256adddbb84ece0b30c9bcaa66d144 (diff) | |
download | cpython-56507c7862b6e2de189b6a942f394efb676cdb0b.zip cpython-56507c7862b6e2de189b6a942f394efb676cdb0b.tar.gz cpython-56507c7862b6e2de189b6a942f394efb676cdb0b.tar.bz2 |
Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
virtual interface. Original patch by Kent Frazier.
Diffstat (limited to 'Lib/uuid.py')
-rw-r--r-- | Lib/uuid.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py index 9226fd4..d5c3160 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -327,8 +327,16 @@ def _find_mac(command, args, hw_identifiers, get_index): 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: continue return None |