summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/int_parse.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-05-23 18:02:32 +1000
committerDamien George <damien@micropython.org>2023-06-01 15:11:06 +1000
commit69dd013919461272b3669a516ef98d60accd3165 (patch)
tree31f5264eae7d4aac34f2c4c33b60ec740e4ed780 /tests/basics/int_parse.py
parent66dc1397c92f6accf102bcd15c6395902fd46c8b (diff)
downloadmicropython-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.py12
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")))