summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-04-26 01:58:53 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-04-26 01:58:53 (GMT)
commit89e3ee0ccff975f30b81b40dec1ee1d7e6b09f9c (patch)
tree08e3db42b3698bfa3bdb623925c93baf43e58b9b /Python
parent93646981011b0795329888bf7d2d10097e899432 (diff)
downloadcpython-89e3ee0ccff975f30b81b40dec1ee1d7e6b09f9c.zip
cpython-89e3ee0ccff975f30b81b40dec1ee1d7e6b09f9c.tar.gz
cpython-89e3ee0ccff975f30b81b40dec1ee1d7e6b09f9c.tar.bz2
If Py_OptimizeFlag is false then always evaluate assert conditions, don't
test __debug__ at runtime. Closes SF patch #548833.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 373363f..03f8e3c 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2664,27 +2664,20 @@ com_expr_stmt(struct compiling *c, node *n)
static void
com_assert_stmt(struct compiling *c, node *n)
{
- int a = 0, b = 0;
+ int a = 0;
int i;
REQ(n, assert_stmt); /* 'assert' test [',' test] */
- /* Generate code like for
+ if (Py_OptimizeFlag)
+ return;
+ /* Generate code like
- if __debug__:
- if not <test>:
+ if not <test>:
raise AssertionError [, <message>]
where <message> is the second test, if present.
*/
-
- if (Py_OptimizeFlag)
- return;
- com_addop_name(c, LOAD_GLOBAL, "__debug__");
- com_push(c, 1);
- com_addfwref(c, JUMP_IF_FALSE, &a);
- com_addbyte(c, POP_TOP);
- com_pop(c, 1);
com_node(c, CHILD(n, 1));
- com_addfwref(c, JUMP_IF_TRUE, &b);
+ com_addfwref(c, JUMP_IF_TRUE, &a);
com_addbyte(c, POP_TOP);
com_pop(c, 1);
/* Raise that exception! */
@@ -2696,9 +2689,8 @@ com_assert_stmt(struct compiling *c, node *n)
com_addoparg(c, RAISE_VARARGS, i);
com_pop(c, i);
/* The interpreter does not fall through */
- /* All jumps converge here */
+ /* Jump ends up here */
com_backpatch(c, a);
- com_backpatch(c, b);
com_addbyte(c, POP_TOP);
}