Fix uuid failure on systems with 64-bit hardware addresses: https://bugs.python.org/issue32502 Backported from: https://github.com/python/cpython/commit/d69794f4df81de731cc66dc82136e28bee691e1e#diff-9d2d23bf4362c9ec2b6dd4b64b73756c --- Lib/uuid.py.orig 2018-08-02 04:19:12.000000000 -0500 +++ Lib/uuid.py 2018-08-26 02:26:30.000000000 -0500 @@ -527,6 +527,12 @@ _node = None +_NODE_GETTERS_WIN32 = [_windll_getnode, _netbios_getnode, _ipconfig_getnode] + +_NODE_GETTERS_UNIX = [_unixdll_getnode, _ifconfig_getnode, _ip_getnode, + _arp_getnode, _lanscan_getnode, _netstat_getnode] + + def getnode(): """Get the hardware address as a 48-bit positive integer. @@ -542,18 +548,18 @@ import sys if sys.platform == 'win32': - getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode] + getters = _NODE_GETTERS_WIN32 else: - getters = [_unixdll_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 invalid value: {}'.format(_node) _last_timestamp = None