From a07fc5b6403b9a8bf7e7cb64f857272e5346d7e2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 21 Nov 2017 15:01:38 +1100 Subject: py/objfloat: Allow float() to parse anything with the buffer protocol. This generalises and simplifies the code and follows CPython behaviour. --- tests/float/float1.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/float/float1.py') diff --git a/tests/float/float1.py b/tests/float/float1.py index c64f965a7..54807e5ac 100644 --- a/tests/float/float1.py +++ b/tests/float/float1.py @@ -36,6 +36,10 @@ try: except ValueError: print("ValueError") +# construct from something with the buffer protocol +print(float(b"1.2")) +print(float(bytearray(b"3.4"))) + # unary operators print(bool(0.0)) print(bool(1.2)) -- cgit v1.2.3