summaryrefslogtreecommitdiffstatshomepage
path: root/py/objmodule.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-08 21:11:49 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-08 21:11:49 +0100
commit1d24ea5207ba4b62b20dbba22ab2800496418463 (patch)
tree0ac953019f01f030778f2bc6381b69884e7124be /py/objmodule.c
parent134c10e776a5d75cfdd6bf98697cb50d7da7adf6 (diff)
downloadmicropython-1d24ea5207ba4b62b20dbba22ab2800496418463.tar.gz
micropython-1d24ea5207ba4b62b20dbba22ab2800496418463.zip
py: Finish implementation of all del opcodes.
At this point, all opcodes are now implemented! Some del opcodes have been combined with store opcodes, with the value to store being MP_OBJ_NULL.
Diffstat (limited to 'py/objmodule.c')
-rw-r--r--py/objmodule.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/py/objmodule.c b/py/objmodule.c
index df7c991b8c..15ccd68ac2 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -27,8 +27,14 @@ STATIC void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
STATIC bool module_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
mp_obj_module_t *self = self_in;
- // TODO CPython allows STORE_ATTR to a module, but is this the correct implementation?
- mp_obj_dict_store(self->globals, MP_OBJ_NEW_QSTR(attr), value);
+ if (value == MP_OBJ_NULL) {
+ // delete attribute
+ mp_obj_dict_delete(self->globals, MP_OBJ_NEW_QSTR(attr));
+ } else {
+ // store attribute
+ // TODO CPython allows STORE_ATTR to a module, but is this the correct implementation?
+ mp_obj_dict_store(self->globals, MP_OBJ_NEW_QSTR(attr), value);
+ }
return true;
}