Commit 2876f5ad authored by Jeremy Hylton's avatar Jeremy Hylton

SF patch 836879.

Don't generate code for asserts in -O mode.
parent 4c989ddc
...@@ -707,15 +707,13 @@ class CodeGenerator: ...@@ -707,15 +707,13 @@ 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
if __debug__:
end = self.newBlock() end = self.newBlock()
self.set_lineno(node) self.set_lineno(node)
# XXX __debug__ and AssertionError appear to be special cases # XXX AssertionError appears to be special case -- it is always
# -- they are always loaded as globals even if there are local # loaded as a global even if there is a local name. I guess this
# names. I guess this is a sort of renaming op. # is a sort of renaming op.
self.emit('LOAD_GLOBAL', '__debug__')
self.emit('JUMP_IF_FALSE', end)
self.nextBlock() self.nextBlock()
self.emit('POP_TOP')
self.visit(node.test) self.visit(node.test)
self.emit('JUMP_IF_TRUE', end) self.emit('JUMP_IF_TRUE', end)
self.nextBlock() self.nextBlock()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment