Open dhalbert opened 4 years ago
I just bumped into this testing the new CP 5.0 release. I had to change code for to_bytes() and just did a global search/replace which made my from_bytes() calls fail.
Thanks for documenting it here, though. Didn't take me long to find this thread and see it's a known issue on the long term list.
I'm running into this issue as well.
Adafruit CircuitPython 8.0.0-beta.6-25-gbb3a1c0a2 on 2023-01-04; Raspberry Pi Pico W with rp2040
>>> (-1).to_bytes(1, 'big', signed=True)
b'\xff'
>>> int.from_bytes(b'\xff', 'big', signed=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedError: signed=True
>>> int.from_bytes(b'\xff', 'big')
255
"// TODO: Support signed param (assumes signed=False at the moment)"
(just waking up this sleeping issue)
Is the underlying code for this vastly different?
>>> struct.pack("b", -1)
b'\xff'
>>> struct.unpack("b", b'\xff')
(-1,)
Related to #2579. This was harder to fix: the underlying longint routines don't handle signed values.