Skip to content

Commit c3e72a8

Browse files
committed
mp_obj_is_callable(): Only object types can be callable.
Fixes segfault on callable("string").
1 parent bc5b3f8 commit c3e72a8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

py/obj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void mp_obj_print_exception(mp_obj_t exc) {
6666
}
6767

6868
bool mp_obj_is_callable(mp_obj_t o_in) {
69-
if (MP_OBJ_IS_SMALL_INT(o_in)) {
69+
if (!MP_OBJ_IS_OBJ(o_in)) {
7070
return false;
7171
} else {
7272
mp_obj_base_t *o = o_in;

tests/basics/builtin-callable.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sys
2+
print(callable(1))
3+
print(callable("dfsd"))
4+
print(callable(callable))
5+
print(callable(sys))

0 commit comments

Comments
 (0)