Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
822963ed
Commit
822963ed
authored
Nov 26, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
virtual interface. Original patch by Kent Frazier.
parents
518e6ee9
56507c78
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
2 deletions
+35
-2
Lib/test/test_uuid.py
Lib/test/test_uuid.py
+21
-0
Lib/uuid.py
Lib/uuid.py
+10
-2
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_uuid.py
View file @
822963ed
import
unittest
from
test
import
support
import
builtins
import
io
import
os
import
uuid
...
...
@@ -356,6 +358,25 @@ class TestUUID(unittest.TestCase):
self
.
assertEqual
(
node1
,
node2
)
def
test_find_mac
(
self
):
data
=
'''
\
fake hwaddr
cscotun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab
'''
def
mock_popen
(
cmd
):
return
io
.
StringIO
(
data
)
with
support
.
swap_attr
(
os
,
'popen'
,
mock_popen
):
mac
=
uuid
.
_find_mac
(
command
=
'ifconfig'
,
args
=
''
,
hw_identifiers
=
[
'hwaddr'
],
get_index
=
lambda
x
:
x
+
1
,
)
self
.
assertEqual
(
mac
,
0x1234567890ab
)
@
unittest
.
skipUnless
(
importable
(
'ctypes'
),
'requires ctypes'
)
def
test_uuid1
(
self
):
equal
=
self
.
assertEqual
...
...
Lib/uuid.py
View file @
822963ed
...
...
@@ -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
:
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
...
...
Misc/ACKS
View file @
822963ed
...
...
@@ -407,6 +407,7 @@ John Fouhy
Andrew Francis
Stefan Franke
Martin Franklin
Kent Frazier
Bruce Frederiksen
Robin Friedrich
Bradley Froehle
...
...
Misc/NEWS
View file @
822963ed
...
...
@@ -16,6 +16,9 @@ Core and Builtins
Library
-------
- Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
virtual interface. Original patch by Kent Frazier.
- Issue #11489: JSON decoder now accepts lone surrogates.
- Issue #19545: Avoid chained exceptions while passing stray % to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment