py/compile2: Don't compile assert statement when optimisations enabled.

This commit is contained in:
Damien George 2017-08-14 12:26:13 +10:00
parent 1db008349c
commit d9d9b0a300
1 changed files with 5 additions and 0 deletions

View File

@ -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