Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
89e3ee0c
Commit
89e3ee0c
authored
Apr 26, 2002
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If Py_OptimizeFlag is false then always evaluate assert conditions, don't
test __debug__ at runtime. Closes SF patch #548833.
parent
93646981
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
15 deletions
+11
-15
Misc/NEWS
Misc/NEWS
+4
-0
Python/compile.c
Python/compile.c
+7
-15
No files found.
Misc/NEWS
View file @
89e3ee0c
...
...
@@ -6,6 +6,10 @@ Type/class unification and new-style classes
Core and builtins
- The assert statement no longer tests __debug__ at runtime. This means
that assert statements cannot be disabled by assigning a false value
to __debug__.
- A method zfill() was added to str and unicode, that fills a numeric
string to the left with zeros. For example,
"+123".zfill(6) -> "+00123".
...
...
Python/compile.c
View file @
89e3ee0c
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment