objgenerator: .print(): Output real underlying function name.
This commit is contained in:
parent
1f85d6255d
commit
c3103b55c1
1
py/obj.h
1
py/obj.h
@ -508,6 +508,7 @@ typedef struct _mp_obj_fun_native_t { // need this so we can define const object
|
||||
|
||||
bool mp_obj_fun_prepare_simple_args(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args,
|
||||
uint *out_args1_len, const mp_obj_t **out_args1, uint *out_args2_len, const mp_obj_t **out_args2);
|
||||
const char *mp_obj_code_get_name(const byte *code_info);
|
||||
|
||||
mp_obj_t mp_identity(mp_obj_t self);
|
||||
MP_DECLARE_CONST_FUN_OBJ(mp_identity_obj);
|
||||
|
@ -126,12 +126,16 @@ mp_obj_t mp_make_function_var_between(int n_args_min, int n_args_max, mp_fun_var
|
||||
/******************************************************************************/
|
||||
/* byte code functions */
|
||||
|
||||
const char *mp_obj_fun_get_name(mp_obj_fun_bc_t *o) {
|
||||
const byte *code_info = o->bytecode;
|
||||
const char *mp_obj_code_get_name(const byte *code_info) {
|
||||
qstr block_name = code_info[8] | (code_info[9] << 8) | (code_info[10] << 16) | (code_info[11] << 24);
|
||||
return qstr_str(block_name);
|
||||
}
|
||||
|
||||
const char *mp_obj_fun_get_name(mp_obj_fun_bc_t *o) {
|
||||
const byte *code_info = o->bytecode;
|
||||
return mp_obj_code_get_name(code_info);
|
||||
}
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
STATIC void fun_bc_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
mp_obj_fun_bc_t *o = o_in;
|
||||
|
@ -68,7 +68,8 @@ typedef struct _mp_obj_gen_instance_t {
|
||||
} mp_obj_gen_instance_t;
|
||||
|
||||
void gen_instance_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
print(env, "<generator object 'fun-name' at %p>", self_in);
|
||||
mp_obj_gen_instance_t *self = self_in;
|
||||
print(env, "<generator object '%s' at %p>", mp_obj_code_get_name(self->code_info), self_in);
|
||||
}
|
||||
|
||||
mp_obj_t gen_instance_getiter(mp_obj_t self_in) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user