summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-08-14 12:26:13 +1000
committerDamien George <damien.p.george@gmail.com>2017-08-14 12:26:13 +1000
commitd9d9b0a3005a810543724622374cc26a5399bd0e (patch)
tree6abf7991049f0adde57729a43522397af5c716bd
parent1db008349cc970fd83b85574492badbf0460ad51 (diff)
downloadmicropython-d9d9b0a3005a810543724622374cc26a5399bd0e.tar.gz
micropython-d9d9b0a3005a810543724622374cc26a5399bd0e.zip
py/compile2: Don't compile assert statement when optimisations enabled.
-rw-r--r--py/compile2.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/compile2.c b/py/compile2.c
index 387d6b4bde..ff496d8fc2 100644
--- a/py/compile2.c
+++ b/py/compile2.c
@@ -1249,6 +1249,11 @@ STATIC void compile_nonlocal_stmt(compiler_t *comp, const byte *p, const byte *p
}
STATIC void compile_assert_stmt(compiler_t *comp, const byte *p, const byte *ptop) {
+ // with optimisations enabled we don't compile assertions
+ if (MP_STATE_VM(mp_optimise_value) != 0) {
+ return;
+ }
+
uint l_end = comp_next_label(comp);
p = c_if_cond(comp, p, true, l_end);
EMIT_LOAD_GLOBAL(MP_QSTR_AssertionError); // we load_global instead of load_id, to be consistent with CPython