Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6b273f7f
Kaydet (Commit)
6b273f7f
authored
Ock 24, 2018
tarafından
Bo Bayles
Kaydeden (comit)
Barry Warsaw
Ock 24, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32502: Discard 64-bit (and other invalid) hardware addresses (#5254)
üst
0bad4d63
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
6 deletions
+38
-6
test_uuid.py
Lib/test/test_uuid.py
+26
-0
uuid.py
Lib/uuid.py
+10
-6
2018-01-20-17-15-34.bpo-32502.OXJfn7.rst
...S.d/next/Library/2018-01-20-17-15-34.bpo-32502.OXJfn7.rst
+2
-0
No files found.
Lib/test/test_uuid.py
Dosyayı görüntüle @
6b273f7f
...
...
@@ -311,6 +311,32 @@ class BaseTestUUID:
node2
=
self
.
uuid
.
getnode
()
self
.
assertEqual
(
node1
,
node2
,
'
%012
x !=
%012
x'
%
(
node1
,
node2
))
# bpo-32502: UUID1 requires a 48-bit identifier, but hardware identifiers
# need not necessarily be 48 bits (e.g., EUI-64).
def
test_uuid1_eui64
(
self
):
# Confirm that uuid.getnode ignores hardware addresses larger than 48
# bits. Mock out each platform's *_getnode helper functions to return
# something just larger than 48 bits to test. This will cause
# uuid.getnode to fall back on uuid._random_getnode, which will
# generate a valid value.
too_large_getter
=
lambda
:
1
<<
48
with
unittest
.
mock
.
patch
.
multiple
(
self
.
uuid
,
_node
=
None
,
# Ignore any cached node value.
_NODE_GETTERS_WIN32
=
[
too_large_getter
],
_NODE_GETTERS_UNIX
=
[
too_large_getter
],
):
node
=
self
.
uuid
.
getnode
()
self
.
assertTrue
(
0
<
node
<
(
1
<<
48
),
'
%012
x'
%
node
)
# Confirm that uuid1 can use the generated node, i.e., the that
# uuid.getnode fell back on uuid._random_getnode() rather than using
# the value from too_large_getter above.
try
:
self
.
uuid
.
uuid1
(
node
=
node
)
except
ValueError
as
e
:
self
.
fail
(
'uuid1 was given an invalid node ID'
)
def
test_uuid1
(
self
):
equal
=
self
.
assertEqual
...
...
Lib/uuid.py
Dosyayı görüntüle @
6b273f7f
...
...
@@ -656,7 +656,12 @@ def _random_getnode():
_node
=
None
def
getnode
():
_NODE_GETTERS_WIN32
=
[
_windll_getnode
,
_netbios_getnode
,
_ipconfig_getnode
]
_NODE_GETTERS_UNIX
=
[
_unix_getnode
,
_ifconfig_getnode
,
_ip_getnode
,
_arp_getnode
,
_lanscan_getnode
,
_netstat_getnode
]
def
getnode
(
*
,
getters
=
None
):
"""Get the hardware address as a 48-bit positive integer.
The first time this runs, it may launch a separate program, which could
...
...
@@ -669,19 +674,18 @@ def getnode():
return
_node
if
sys
.
platform
==
'win32'
:
getters
=
[
_windll_getnode
,
_netbios_getnode
,
_ipconfig_getnode
]
getters
=
_NODE_GETTERS_WIN32
else
:
getters
=
[
_unix_getnode
,
_ifconfig_getnode
,
_ip_getnode
,
_arp_getnode
,
_lanscan_getnode
,
_netstat_getnode
]
getters
=
_NODE_GETTERS_UNIX
for
getter
in
getters
+
[
_random_getnode
]:
try
:
_node
=
getter
()
except
:
continue
if
_node
is
not
None
:
if
(
_node
is
not
None
)
and
(
0
<=
_node
<
(
1
<<
48
))
:
return
_node
assert
False
,
'_random_getnode() returned
None'
assert
False
,
'_random_getnode() returned
invalid value: {}'
.
format
(
_node
)
_last_timestamp
=
None
...
...
Misc/NEWS.d/next/Library/2018-01-20-17-15-34.bpo-32502.OXJfn7.rst
0 → 100644
Dosyayı görüntüle @
6b273f7f
uuid.uuid1 no longer raises an exception if a 64-bit hardware address is
encountered.
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