GH-85724: Ignore the MAC from the Touch Bar interface on macOS in uuid#99717
GH-85724: Ignore the MAC from the Touch Bar interface on macOS in uuid#99717ronaldoussoren wants to merge 3 commits intopython:mainfrom
Conversation
…in uuid All Intel MacBook Pro devices with a Touch Bar have a network interface connected to a controller for that device that has the same MAC address for all MacBooks. Ignore these MAC adresses in the UUID library.
|
One thing I haven't seriously looked into yet is how to include tests for my changes, other than a trivial change to test_uuid that will ensure tests fail on an affected device without the changes to uuid.py. I have manually checked that uuid.uuid1() does not use the MAC address for the Touch Bar interface on an affected device. |
1. Remove the "BLACKLIST" variable as it is both lazy naming not necessary 2. Be more explicit in tests 3. Add test that checks that the mac touchbar mac is actually ignored.
| _UuidCreate = getattr(_uuid, "UuidCreate", None) | ||
| _has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe | ||
|
|
||
| if sys.platform == "darwin" and _generate_time_safe is not None: |
There was a problem hiding this comment.
I'm not 100% sure about this test, and in particular not about the test for "darwin".
There are people running Linux on Apple hardware and I don't know if those could be affected by this issue, in particular if there is a driver that exposes a ethernet-like interface to the Touch Bar hardware.
| _x = _generate_time_safe()[0] | ||
| if _x.endswith(bytes.fromhex(_MACOS_TOUCHBAR_MAC.replace(":", ""))): | ||
| _has_uuid_generate_time_safe = False | ||
| _generate_time_safe = None |
There was a problem hiding this comment.
Would it make sense/be possible to implement this test directly in the _uuid module: remove the function if it returns this address?
There was a problem hiding this comment.
Hmmm... Possible yes, sensible maybe not.
The implementation of _uuid.generate_time_safe has 3 or 4 variants (depending on how you count) and because of that an implementation in C mirrors the Python code above but is more verbose and likely not faster than the Python implementation.
I have a patch, but haven't tested it on a device with a Touch Bar yet. That patch adds 49 lines of code to _uuidmodule.c and removes the 4 lines of python code above.


All Intel MacBook Pro devices with a Touch Bar have a network interface connected to a controller for that device that has the same MAC address for all MacBooks.
Ignore these MAC adresses in the UUID library.