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
2876f5ad
Commit
2876f5ad
authored
Aug 07, 2004
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF patch 836879.
Don't generate code for asserts in -O mode.
parent
4c989ddc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
Lib/compiler/pycodegen.py
Lib/compiler/pycodegen.py
+19
-21
No files found.
Lib/compiler/pycodegen.py
View file @
2876f5ad
...
@@ -707,27 +707,25 @@ class CodeGenerator:
...
@@ -707,27 +707,25 @@ class CodeGenerator:
def
visitAssert
(
self
,
node
):
def
visitAssert
(
self
,
node
):
# XXX would be interesting to implement this via a
# XXX would be interesting to implement this via a
# transformation of the AST before this stage
# transformation of the AST before this stage
end
=
self
.
newBlock
()
if
__debug__
:
self
.
set_lineno
(
node
)
end
=
self
.
newBlock
()
# XXX __debug__ and AssertionError appear to be special cases
self
.
set_lineno
(
node
)
# -- they are always loaded as globals even if there are local
# XXX AssertionError appears to be special case -- it is always
# names. I guess this is a sort of renaming op.
# loaded as a global even if there is a local name. I guess this
self
.
emit
(
'LOAD_GLOBAL'
,
'__debug__'
)
# is a sort of renaming op.
self
.
emit
(
'JUMP_IF_FALSE'
,
end
)
self
.
nextBlock
()
self
.
nextBlock
()
self
.
visit
(
node
.
test
)
self
.
emit
(
'POP_TOP'
)
self
.
emit
(
'JUMP_IF_TRUE'
,
end
)
self
.
visit
(
node
.
test
)
self
.
nextBlock
()
self
.
emit
(
'JUMP_IF_TRUE'
,
end
)
self
.
emit
(
'POP_TOP'
)
self
.
nextBlock
()
self
.
emit
(
'LOAD_GLOBAL'
,
'AssertionError'
)
self
.
emit
(
'POP_TOP'
)
if
node
.
fail
:
self
.
emit
(
'LOAD_GLOBAL'
,
'AssertionError'
)
self
.
visit
(
node
.
fail
)
if
node
.
fail
:
self
.
emit
(
'RAISE_VARARGS'
,
2
)
self
.
visit
(
node
.
fail
)
else
:
self
.
emit
(
'RAISE_VARARGS'
,
2
)
self
.
emit
(
'RAISE_VARARGS'
,
1
)
else
:
self
.
nextBlock
(
end
)
self
.
emit
(
'RAISE_VARARGS'
,
1
)
self
.
emit
(
'POP_TOP'
)
self
.
nextBlock
(
end
)
self
.
emit
(
'POP_TOP'
)
def
visitRaise
(
self
,
node
):
def
visitRaise
(
self
,
node
):
self
.
set_lineno
(
node
)
self
.
set_lineno
(
node
)
...
...
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