Barry A. Warsaw <ba...@python.org> added the comment:

On Nov 23, 2017, at 11:24, Serhiy Storchaka <rep...@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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32107>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to