Verified Commit 0a12dc75 authored by Rahix's avatar Rahix
Browse files

fix(pycardium): Actually enable UUID module


Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent ec12a3cc
...@@ -20,6 +20,7 @@ python_modules = files( ...@@ -20,6 +20,7 @@ python_modules = files(
'string.py', 'string.py',
'struct.py', 'struct.py',
'ucontextlib.py', 'ucontextlib.py',
'uuid.py',
) )
frozen_modules = mpy_cross.process(python_modules) frozen_modules = mpy_cross.process(python_modules)
...@@ -20,7 +20,7 @@ class UUID: ...@@ -20,7 +20,7 @@ class UUID:
if len(bytes) != 16: if len(bytes) != 16:
raise ValueError("bytes is not a 16-char string") raise ValueError("bytes is not a 16-char string")
assert isinstance(bytes, bytes_), repr(bytes) assert isinstance(bytes, bytes_), repr(bytes)
int = int_.from_bytes(bytes, byteorder="big") int = int_.from_bytes(bytes, "big")
if int is not None: if int is not None:
if not 0 <= int < 1 << 128: if not 0 <= int < 1 << 128:
raise ValueError("int is out of range (need a 128-bit value)") raise ValueError("int is out of range (need a 128-bit value)")
...@@ -33,7 +33,8 @@ class UUID: ...@@ -33,7 +33,8 @@ class UUID:
# Set the version number. # Set the version number.
int &= ~(0xF000 << 64) int &= ~(0xF000 << 64)
int |= version << 76 int |= version << 76
self.__dict__["int"] = int
setattr(self, "int", int)
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, UUID): if isinstance(other, UUID):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment