summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-12 04:26:54 -0800
committerDamien George <damien.p.george@gmail.com>2014-01-12 04:26:54 -0800
commitc0876f7ca8cc56597a99144bf6fac0f021334c1a (patch)
tree09b21b7575c56ca05160dccc7c142f3a67d64e07 /py
parent89cbded00087bb84a0db04b3927e024cdddf4497 (diff)
parentb81e1fdef742675b1e285df80c39159f0bdbf90b (diff)
downloadmicropython-c0876f7ca8cc56597a99144bf6fac0f021334c1a.tar.gz
micropython-c0876f7ca8cc56597a99144bf6fac0f021334c1a.zip
Merge pull request #146 from pfalcon/assert-exc
Add AssertionError.
Diffstat (limited to 'py')
-rw-r--r--py/emitpass1.c5
-rw-r--r--py/runtime.c1
2 files changed, 2 insertions, 4 deletions
diff --git a/py/emitpass1.c b/py/emitpass1.c
index 2f0ecac86d..60fdd0b825 100644
--- a/py/emitpass1.c
+++ b/py/emitpass1.c
@@ -45,10 +45,7 @@ static void emit_pass1_load_id(emit_t *emit, qstr qstr) {
bool added;
id_info_t *id = scope_find_or_add_id(emit->scope, qstr, &added);
if (added) {
- if (qstr == MP_QSTR_AssertionError) {
- // TODO how much of a hack is this?
- id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT;
- } else if (strcmp(qstr_str(qstr), "super") == 0 && emit->scope->kind == SCOPE_FUNCTION) {
+ if (strcmp(qstr_str(qstr), "super") == 0 && emit->scope->kind == SCOPE_FUNCTION) {
// special case, super is a global, and also counts as use of __class__
id->kind = ID_INFO_KIND_GLOBAL_EXPLICIT;
id_info_t *id2 = scope_find_local_in_parent(emit->scope, emit->qstr___class__);
diff --git a/py/runtime.c b/py/runtime.c
index b982ee32d0..8d3e900286 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -90,6 +90,7 @@ void rt_init(void) {
mp_map_add_qstr(&map_builtins, MP_QSTR_SyntaxError, mp_obj_new_exception(MP_QSTR_SyntaxError));
mp_map_add_qstr(&map_builtins, MP_QSTR_ValueError, mp_obj_new_exception(MP_QSTR_ValueError));
mp_map_add_qstr(&map_builtins, MP_QSTR_OSError, mp_obj_new_exception(MP_QSTR_OSError));
+ mp_map_add_qstr(&map_builtins, MP_QSTR_AssertionError, mp_obj_new_exception(MP_QSTR_AssertionError));
// built-in objects
mp_map_add_qstr(&map_builtins, MP_QSTR_Ellipsis, mp_const_ellipsis);