Message306854
On Nov 23, 2017, at 11:24, Serhiy Storchaka <report@bugs.python.org> wrote:
> Wait, now I understand the purpose of the current test! There is just a typo in a comment, should be 41 instead of 47. The test itself is correct. If the address is obtained from network cards, it should have the 41 bit clear. If it is generated randomly, it should have the 41 bit set, to avoid conflicts with addresses obtained from network cards. There is nothing about the 42 bit.
It’s not just a typo in the comment, it’s a typo in the bitmask, at least if the intent of the test is to ensure that the MAC address is universally administered. That is defined as having a 0 in the “second least significant bit of the first octet”. Here’s a way to make that clearer.
# Second least significant bit of the first octet of the 48-bit MAC address
>>> 0b00000010_00000000_00000000_00000000_00000000_00000000
2199023255552
# Constant from the PR
>>> 1<<41
2199023255552
# Literal bit mask from the original code.
>>> 0x010000000000
1099511627776
The latter is off by 1 place. |
|
Date |
User |
Action |
Args |
2017-11-23 19:31:23 | barry | set | recipients:
+ barry, vstinner, serhiy.storchaka |
2017-11-23 19:31:23 | barry | link | issue32107 messages |
2017-11-23 19:31:23 | barry | create | |
|