diff options
author | Damien George <damien.p.george@gmail.com> | 2016-08-26 22:28:22 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-08-26 22:28:22 +1000 |
commit | 24df30c1336fc72ad7dcd5cfc08a5e7f9a1f9808 (patch) | |
tree | b98ea1c486a2963d6045932f2be0d74960a728a2 /py | |
parent | fc73c9b4b28e903641888a81a76169a929407383 (diff) | |
download | micropython-24df30c1336fc72ad7dcd5cfc08a5e7f9a1f9808.tar.gz micropython-24df30c1336fc72ad7dcd5cfc08a5e7f9a1f9808.zip |
py/compile: Don't compile assert statements when optimisations enabled.
As per CPython.
Diffstat (limited to 'py')
-rw-r--r-- | py/compile.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/compile.c b/py/compile.c index df6dab063c..c8b4e5470d 100644 --- a/py/compile.c +++ b/py/compile.c @@ -1200,6 +1200,11 @@ STATIC void compile_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) } STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { + // with optimisations enabled we don't compile assertions + if (MP_STATE_VM(mp_optimise_value) != 0) { + return; + } + uint l_end = comp_next_label(comp); c_if_cond(comp, pns->nodes[0], true, l_end); EMIT_LOAD_GLOBAL(MP_QSTR_AssertionError); // we load_global instead of load_id, to be consistent with CPython |