aboutsummaryrefslogtreecommitdiff
path: root/tests/extmod
diff options
context:
space:
mode:
authorDamien George2019-08-22 15:22:42 +1000
committerDamien George2019-08-22 15:32:26 +1000
commit2dfa69efbbae92faf21360edd5e60c5a9145a2dc (patch)
tree4fac20d1eb09447e58cd5ecf332ddc9166551b4e /tests/extmod
parent8e7745eb315cdaf7dec033891f88e091ab4e016e (diff)
extmod/modujson: Support passing bytes/bytearray to json.loads.
CPython allows this, and it can be useful to reduce the number of memory allocations. Fixes issue #5031.
Diffstat (limited to 'tests/extmod')
-rw-r--r--tests/extmod/ujson_loads.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/extmod/ujson_loads.py b/tests/extmod/ujson_loads.py
index adba3c068..43672d650 100644
--- a/tests/extmod/ujson_loads.py
+++ b/tests/extmod/ujson_loads.py
@@ -37,6 +37,10 @@ my_print(json.loads('"abc\\uabcd"'))
# whitespace handling
my_print(json.loads('{\n\t"a":[]\r\n, "b":[1], "c":{"3":4} \n\r\t\r\r\r\n}'))
+# loading from bytes and bytearray
+my_print(json.loads(b'[1,2]'))
+my_print(json.loads(bytearray(b'[null]')))
+
# loading nothing should raise exception
try:
json.loads('')