Problem with MP_BC_SETUP_WITH bytecode

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
hadi
Posts: 2
Joined: Wed Feb 06, 2019 3:43 pm

Problem with MP_BC_SETUP_WITH bytecode

Post by hadi » Sat Mar 09, 2019 11:28 am

Hi
I think there is a problem with byte code "MP_BC_SETUP_WITH".

ENTRY(MP_BC_SETUP_WITH): {
MARK_EXC_IP_SELECTIVE();
// stack: (..., ctx_mgr)
mp_obj_t obj = TOP();
mp_load_method(obj, MP_QSTR___exit__, sp);
mp_load_method(obj, MP_QSTR___enter__, sp + 2);
mp_obj_t ret = mp_call_method_n_kw(0, 0, sp + 2);
sp += 1;
PUSH_EXC_BLOCK(1);
PUSH(ret);
// stack: (..., __exit__, ctx_mgr, as_value)
DISPATCH();
}
[url=https://github.com/micropython/micropyt ... er/py/vm.c]vm.c[/url]

at first object "ctx_mgr" will save to "obj" variable and we never push it on stack again. when the line "mp_load_method(obj, MP_QSTR___exit__, sp);" execute the top of stack(ctx_mgr) will substitute with "__exit__" object and we have missed "ctx_mgr" object.

Post Reply