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
a5a72a86
Commit
a5a72a86
authored
Dec 17, 2013
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19855: uuid.get_node now looks on the PATH for executables on unix.
Patch by Serhiy Storchaka.
parent
e388e623
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
25 deletions
+34
-25
Lib/uuid.py
Lib/uuid.py
+30
-25
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/uuid.py
View file @
a5a72a86
...
...
@@ -293,33 +293,38 @@ class UUID(object):
def
_find_mac
(
command
,
args
,
hw_identifiers
,
get_index
):
import
os
for
dir
in
[
''
,
'/sbin/'
,
'/usr/sbin'
]:
path
=
os
.
environ
.
get
(
"PATH"
,
os
.
defpath
).
split
(
os
.
pathsep
)
path
.
extend
((
'/sbin'
,
'/usr/sbin'
))
for
dir
in
path
:
executable
=
os
.
path
.
join
(
dir
,
command
)
if
not
os
.
path
.
exists
(
executable
):
continue
if
(
os
.
path
.
exists
(
executable
)
and
os
.
access
(
executable
,
os
.
F_OK
|
os
.
X_OK
)
and
not
os
.
path
.
isdir
(
executable
)):
break
else
:
return
None
try
:
# LC_ALL to get English output, 2>/dev/null to
# prevent output on stderr
cmd
=
'LC_ALL=C %s %s 2>/dev/null'
%
(
executable
,
args
)
with
os
.
popen
(
cmd
)
as
pipe
:
for
line
in
pipe
:
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
IOError
:
continue
return
None
try
:
# LC_MESSAGES to get English output, 2>/dev/null to
# prevent output on stderr
cmd
=
'LC_MESSAGES=C %s %s 2>/dev/null'
%
(
executable
,
args
)
with
os
.
popen
(
cmd
)
as
pipe
:
for
line
in
pipe
:
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
IOError
:
pass
def
_ifconfig_getnode
():
"""Get the hardware address on Unix by running ifconfig."""
...
...
Misc/NEWS
View file @
a5a72a86
...
...
@@ -27,6 +27,10 @@ Core and Builtins
Library
-------
- Issue #19855: uuid.getnode() on Unix now looks on the PATH for the
executables used to find the mac address, with /sbin and /usr/sbin as
fallbacks.
- Issue #20007: HTTPResponse.read(0) no more prematurely closes connection.
Original patch by Simon Sapin.
...
...
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