mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
virtual interface. Original patch by Kent Frazier.
This commit is contained in:
commit
822963ed5d
4 changed files with 35 additions and 2 deletions
12
Lib/uuid.py
12
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 OSError:
|
||||
continue
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue