Skip to content

Commit bace1a1

Browse files
committed
py/objtype: Don't expose mp_obj_instance_attr().
mp_obj_is_instance_type() can be used instead to check for instance types.
1 parent db5d8c9 commit bace1a1

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

py/objtype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ STATIC bool mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t val
764764
}
765765
}
766766

767-
void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
767+
STATIC void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
768768
if (dest[0] == MP_OBJ_NULL) {
769769
mp_obj_instance_load_attr(self_in, attr, dest);
770770
} else {

py/objtype.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ typedef struct _mp_obj_instance_t {
4242
mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *cls, const mp_obj_type_t **native_base);
4343
#endif
4444

45-
// this needs to be exposed for MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE to work
46-
void mp_obj_instance_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
47-
4845
// these need to be exposed so mp_obj_is_callable can work correctly
4946
bool mp_obj_instance_is_callable(mp_obj_t self_in);
5047
mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);

py/vm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ run_code_state: ;
336336
MARK_EXC_IP_SELECTIVE();
337337
DECODE_QSTR;
338338
mp_obj_t top = TOP();
339-
if (mp_obj_get_type(top)->attr == mp_obj_instance_attr) {
339+
if (mp_obj_is_instance_type(mp_obj_get_type(top))) {
340340
mp_obj_instance_t *self = MP_OBJ_TO_PTR(top);
341341
mp_uint_t x = *ip;
342342
mp_obj_t key = MP_OBJ_NEW_QSTR(qst);
@@ -434,7 +434,7 @@ run_code_state: ;
434434
MARK_EXC_IP_SELECTIVE();
435435
DECODE_QSTR;
436436
mp_obj_t top = TOP();
437-
if (mp_obj_get_type(top)->attr == mp_obj_instance_attr && sp[-1] != MP_OBJ_NULL) {
437+
if (mp_obj_is_instance_type(mp_obj_get_type(top)) && sp[-1] != MP_OBJ_NULL) {
438438
mp_obj_instance_t *self = MP_OBJ_TO_PTR(top);
439439
mp_uint_t x = *ip;
440440
mp_obj_t key = MP_OBJ_NEW_QSTR(qst);

0 commit comments

Comments
 (0)