1 comment:
Patchset:
It turns out there *is* a surprising difference!
The rstrip() version causes this error in pySim.esim.saip, can you guess why:
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/saip/personalization.py", line 560, in decimal_hex_to_str
return val.to_bytes().decode('ascii')
^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'to_bytes'
I stared for a while until I realized this code is using hexstr.to_bytes(). (hexstr is also here from pyosmocom.)
hexstr has a magic trick:
def __getitem__(self, val) -> 'hexstr':
# make sure slicing a hexstr will return a hexstr
return hexstr(super().__getitem__(val))
so with the unrpad() implementation from this patch, a hexstr stays a hexstr.
When using val.rstrip('f'), the hexstr becomes a str, and then there is no to_bytes() function.
For now I solved it in the calling code as a local function
def unrpad(s: hexstr, c='f') -> hexstr:
return hexstr(s.rstrip(c))
but something like this next to rpad() now seems useful again... what do you think?
To view, visit change 39600. To unsubscribe, or for help writing mail filters, visit settings.