mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
py/objint: Allow int() to parse anything with the buffer protocol.
This generalises and simplifies the code and follows CPython behaviour.
See similar change for floats in a07fc5b640.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
12
tests/basics/int_parse.py
Normal file
12
tests/basics/int_parse.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# Test parsing ints.
|
||||
|
||||
try:
|
||||
bytearray
|
||||
memoryview
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
print(int(b"123"))
|
||||
print(int(bytearray(b"123")))
|
||||
print(int(memoryview(b"123")))
|
||||
Reference in New Issue
Block a user