Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Unified Diff: Lib/uuid.py

Issue 11508: Virtual Interfaces cause uuid._find_mac to raise a ValueError under Linux
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Lib/test/test_uuid.py ('K') | « Lib/test/test_uuid.py ('k') | Misc/ACKS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/uuid.py Mon Mar 14 10:56:33 2011 -0400
+++ b/Lib/uuid.py Mon Mar 14 17:21:28 2011 -0400
@@ -327,8 +327,16 @@
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)
+ # 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
+ except ValueError:
storchaka 2013/10/27 14:09:20 Perhaps we should catch IndexError too.
kfrazier 2013/10/31 03:36:29 It might be appropriate to catch it, but I don't k
storchaka 2013/11/09 21:08:31 If a line ends with 'hwaddr' or 'ether'.
+ continue
except IOError:
continue
return None
« Lib/test/test_uuid.py ('K') | « Lib/test/test_uuid.py ('k') | Misc/ACKS » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+