python-build-standalone: `uuid.get_node` is failing to find a stable identifier

❯ uvx python -c "import uuid; print(uuid.getnode())"
87776899200804
❯ uvx python -c "import uuid; print(uuid.getnode())"
16554352112436
❯ uvx --no-managed-python python -c "import uuid; print(uuid.getnode())"
178803724683704
❯ uvx --no-managed-python python -c "import uuid; print(uuid.getnode())"
178803724683704

https://docs.python.org/3/library/uuid.html#uuid.getnode

… If all attempts to obtain the hardware address fail, we choose a random 48-bit number with the multicast bit (least significant bit of the first octet) set to 1 as recommended in RFC 4122.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 19 (11 by maintainers)

Commits related to this issue

Most upvoted comments

This feels like a CPython bug/quirk. The code prefers obtaining a random time for the node value on Linux if a C function is available. It then falls back to trying to find an actual hardware value.

Feels like the ordering is wrong. But this may have been a choice to favor performance or security or something. But it isn’t documented inline in uuid.py.