summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-01 22:20:07 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-01 23:22:11 +0300
commitc3103b55c1cbd6d28ff5ef310a4e731780ff391a (patch)
tree883ba9e2b95650d660c9e20c18cdd8eca659cc62 /py
parent1f85d6255d6929edbcfc087e4e07c2fde39c3632 (diff)
downloadmicropython-c3103b55c1cbd6d28ff5ef310a4e731780ff391a.tar.gz
micropython-c3103b55c1cbd6d28ff5ef310a4e731780ff391a.zip
objgenerator: .print(): Output real underlying function name.
Diffstat (limited to 'py')
-rw-r--r--py/obj.h1
-rw-r--r--py/objfun.c8
-rw-r--r--py/objgenerator.c3
3 files changed, 9 insertions, 3 deletions
diff --git a/py/obj.h b/py/obj.h
index 35c98d3714..ea4534bb25 100644
--- a/py/obj.h
+++ b/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);
diff --git a/py/objfun.c b/py/objfun.c
index 94f6d26d7e..f4d9dfb95e 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -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;
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 895c03cc23..d02f838afe 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -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) {