-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
MemoryResolver.resolve() returns bytearray slices, which is ultimately what array_impl.to_bytes() uses. Python 3.13 enforces that __bytes__ must return bytes, not bytearray, so this error turns up
File "libdestruct/common/obj.py", line 136, in __bytes__
return self.to_bytes()
File "libdestruct/common/array/array_impl.py", line 63, in to_bytes
return b"".join(bytes(x) for x in self)
TypeError: __bytes__ returned non-bytes (type bytearray)
Minimal script derived from what I was trying to do:
from libdestruct import inflater
from libdestruct.c.struct_parser import definition_to_type
MyStruct = definition_to_type("""
struct Foo {
char name[8];
};
""")
lib = inflater(bytearray(b"AAAAAAAA"))
provola = lib.inflate(MyStruct, 0)
bytes(provola)
Fix: memory_resolver.py:48:
- return self.memory[address : address + size]
+ return bytes(self.memory[address : address + size])Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels