-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-28009: Fix uuid.uuid1() and uuid.get_node() on AIX #8672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
4ed41e9
ba47933
c6029a4
7e1874d
6a5bccb
a98309b
53ef750
6fd5f8e
3bb1c08
1af8e3d
d3eaab9
3469a01
399e8ec
6e2a9bf
bb3a460
db6767f
25d3ef1
fa9b43b
4a0c8f0
6463707
a0ef760
095e221
ec4c0e8
70a45f0
b1b4952
8f0687a
4756670
c55714a
10f272e
27b6c32
33969b9
7a57734
4628cea
d2830a2
0688727
ff1ee20
083e9c6
30cd017
27a972b
543e66d
588fda7
28f7a01
6fc2129
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,9 @@ | |
|
|
||
| __author__ = 'Ka-Ping Yee <ping@zesty.ca>' | ||
|
|
||
| _AIX = sys.platform.startswith("aix") | ||
| _MAC_DELIM = b':' if not _AIX else b'.' | ||
|
taleinat marked this conversation as resolved.
Outdated
|
||
|
|
||
| RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [ | ||
| 'reserved for NCS compatibility', 'specified in RFC 4122', | ||
| 'reserved for Microsoft compatibility', 'reserved for future definition'] | ||
|
|
@@ -373,7 +376,7 @@ def _find_mac(command, args, hw_identifiers, get_index): | |
| if words[i] in hw_identifiers: | ||
| try: | ||
| word = words[get_index(i)] | ||
| mac = int(word.replace(b':', b''), 16) | ||
| mac = int(word.replace(_MAC_DELIM, b''), 16) | ||
| if _is_universal(mac): | ||
| return mac | ||
| first_local_mac = first_local_mac or mac | ||
|
|
@@ -455,8 +458,18 @@ def _netstat_getnode(): | |
| try: | ||
| words = line.rstrip().split() | ||
| word = words[i] | ||
| if len(word) == 17 and word.count(b':') == 5: | ||
| mac = int(word.replace(b':', b''), 16) | ||
| if word.count(_MAC_DELIM) == 5: | ||
| if len(word) == 17: | ||
| mac = int(word.replace(_MAC_DELIM, b''), 16) | ||
| # the extracted hex string will not be a 12 hex digit | ||
| # string, so extract the fields and add them in | ||
| # piece by piece | ||
| elif len(word) < 17 and len(word) >= 11: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this change. Is it only needed on AIX? I would prefer to keep ==17 test on other platforms.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I do not have access to other platforms I was trying to write something that was generic. Otherwise a macaddr from: returns as: If you still want it changed, please comment again after push in about 5 minutes)
taleinat marked this conversation as resolved.
Outdated
|
||
| mac = 0 | ||
| hexs = word.split(_MAC_DELIM) | ||
| for hex in hexs: | ||
| mac <<= 8 | ||
| mac += int(hex, 16) | ||
| if _is_universal(mac): | ||
| return mac | ||
| first_local_mac = first_local_mac or mac | ||
|
|
@@ -663,6 +676,8 @@ def _random_getnode(): | |
| _NODE_GETTERS_UNIX = [_unix_getnode, _ifconfig_getnode, _ip_getnode, | ||
| _arp_getnode, _lanscan_getnode, _netstat_getnode] | ||
|
|
||
| _NODE_GETTERS_AIX = [_unix_getnode, _netstat_getnode] | ||
|
taleinat marked this conversation as resolved.
Outdated
|
||
|
|
||
| def getnode(*, getters=None): | ||
| """Get the hardware address as a 48-bit positive integer. | ||
|
|
||
|
|
@@ -678,7 +693,7 @@ def getnode(*, getters=None): | |
| if sys.platform == 'win32': | ||
| getters = _NODE_GETTERS_WIN32 | ||
| else: | ||
| getters = _NODE_GETTERS_UNIX | ||
| getters = _NODE_GETTERS_UNIX if not _AIX else _NODE_GETTERS_AIX | ||
|
|
||
| for getter in getters + [_random_getnode]: | ||
| try: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix uuid.uuid1() and uuid.get_node() on AIX |
Uh oh!
There was an error while loading. Please reload this page.