mirror of
https://github.com/micropython/micropython.git
synced 2026-01-09 05:30:27 +01:00
mp_obj_is_callable(): Only object types can be callable.
Fixes segfault on callable("string").
This commit is contained in:
2
py/obj.c
2
py/obj.c
@@ -66,7 +66,7 @@ void mp_obj_print_exception(mp_obj_t exc) {
|
||||
}
|
||||
|
||||
bool mp_obj_is_callable(mp_obj_t o_in) {
|
||||
if (MP_OBJ_IS_SMALL_INT(o_in)) {
|
||||
if (!MP_OBJ_IS_OBJ(o_in)) {
|
||||
return false;
|
||||
} else {
|
||||
mp_obj_base_t *o = o_in;
|
||||
|
||||
5
tests/basics/builtin-callable.py
Normal file
5
tests/basics/builtin-callable.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import sys
|
||||
print(callable(1))
|
||||
print(callable("dfsd"))
|
||||
print(callable(callable))
|
||||
print(callable(sys))
|
||||
Reference in New Issue
Block a user