diff options
author | Damien George <damien@micropython.org> | 2023-05-23 18:02:32 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-06-01 15:11:06 +1000 |
commit | 69dd013919461272b3669a516ef98d60accd3165 (patch) | |
tree | 31f5264eae7d4aac34f2c4c33b60ec740e4ed780 /tests/basics/int_parse.py | |
parent | 66dc1397c92f6accf102bcd15c6395902fd46c8b (diff) | |
download | micropython-69dd013919461272b3669a516ef98d60accd3165.tar.gz micropython-69dd013919461272b3669a516ef98d60accd3165.zip |
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 a07fc5b6403b9a8bf7e7cb64f857272e5346d7e2.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/basics/int_parse.py')
-rw-r--r-- | tests/basics/int_parse.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/basics/int_parse.py b/tests/basics/int_parse.py new file mode 100644 index 0000000000..cc41158c59 --- /dev/null +++ b/tests/basics/int_parse.py @@ -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"))) |