summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2017-11-28 22:26:04 (GMT)
committerGitHub <noreply@github.com>2017-11-28 22:26:04 (GMT)
commit23df2d1304ece169d7e0dfc843dfb8026b413d9f (patch)
treea7fdbffe4a5dc8e21f5b4a0734e5811451cc2aed /Doc/library
parent71bd588646b282c9eebc390b31184a5bdb54e712 (diff)
downloadcpython-23df2d1304ece169d7e0dfc843dfb8026b413d9f.zip
cpython-23df2d1304ece169d7e0dfc843dfb8026b413d9f.tar.gz
cpython-23df2d1304ece169d7e0dfc843dfb8026b413d9f.tar.bz2
bpo-32107 - Improve MAC address calculation and fix test_uuid.py (#4600)
``uuid.getnode()`` now preferentially returns universally administered MAC addresses if available, over locally administered MAC addresses. This makes a better guarantee for global uniqueness of UUIDs returned from ``uuid.uuid1()``. If only locally administered MAC addresses are available, the first such one found is returned. Also improve internal code style by being explicit about ``return None`` rather than falling off the end of the function. Improve the test robustness.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/uuid.rst16
1 files changed, 12 insertions, 4 deletions
diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst
index ea9ea7d..8ec75a7 100644
--- a/Doc/library/uuid.rst
+++ b/Doc/library/uuid.rst
@@ -156,10 +156,18 @@ The :mod:`uuid` module defines the following functions:
Get the hardware address as a 48-bit positive integer. The first time this
runs, it may launch a separate program, which could be quite slow. If all
- attempts to obtain the hardware address fail, we choose a random 48-bit number
- with its eighth bit set to 1 as recommended in RFC 4122. "Hardware address"
- means the MAC address of a network interface, and on a machine with multiple
- network interfaces the MAC address of any one of them may be returned.
+ attempts to obtain the hardware address fail, we choose a random 48-bit
+ number with the multicast bit (least significant bit of the first octet)
+ set to 1 as recommended in RFC 4122. "Hardware address" means the MAC
+ address of a network interface. On a machine with multiple network
+ interfaces, universally administered MAC addresses (i.e. where the second
+ least significant bit of the first octet is *unset*) will be preferred over
+ locally administered MAC addresses, but with no other ordering guarantees.
+
+ .. versionchanged:: 3.7
+ Universally administered MAC addresses are preferred over locally
+ administered MAC addresses, since the former are guaranteed to be
+ globally unique, while the latter are not.
.. index:: single: getnode