extmod: Make ujson.loads raise exception if given empty string.
Addresses issue #1097.
This commit is contained in:
parent
e8b877be60
commit
5f64dc55d8
|
@ -239,7 +239,8 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
|
|||
// unexpected chars
|
||||
goto fail;
|
||||
}
|
||||
if (stack.len != 0) {
|
||||
if (stack_top == MP_OBJ_NULL || stack.len != 0) {
|
||||
// not exactly 1 object
|
||||
goto fail;
|
||||
}
|
||||
vstr_clear(&vstr);
|
||||
|
|
|
@ -33,3 +33,9 @@ my_print(json.loads('{"a":[], "b":[1], "c":{"3":4}}'))
|
|||
|
||||
# whitespace handling
|
||||
my_print(json.loads('{\n\t"a":[]\r\n, "b":[1], "c":{"3":4} \n\r\t\r\r\r\n}'))
|
||||
|
||||
# loading nothing should raise exception
|
||||
try:
|
||||
json.loads('')
|
||||
except ValueError:
|
||||
print('ValueError')
|
||||
|
|
Loading…
Reference in New Issue