[Python-checkins] python/dist/src/Lib/compiler pycodegen.py, 1.70,
1.71
jhylton at users.sourceforge.net
jhylton at users.sourceforge.net
Sat Aug 7 21:21:58 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/compiler
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9546/Lib/compiler
Modified Files:
pycodegen.py
Log Message:
SF patch 836879.
Don't generate code for asserts in -O mode.
Index: pycodegen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v
retrieving revision 1.70
retrieving revision 1.71
diff -C2 -d -r1.70 -r1.71
*** pycodegen.py 4 Aug 2004 02:36:17 -0000 1.70
--- pycodegen.py 7 Aug 2004 19:21:56 -0000 1.71
***************
*** 708,732 ****
# XXX would be interesting to implement this via a
# transformation of the AST before this stage
! end = self.newBlock()
! self.set_lineno(node)
! # XXX __debug__ and AssertionError appear to be special cases
! # -- they are always loaded as globals even if there are local
! # names. I guess this is a sort of renaming op.
! self.emit('LOAD_GLOBAL', '__debug__')
! self.emit('JUMP_IF_FALSE', end)
! self.nextBlock()
! self.emit('POP_TOP')
! self.visit(node.test)
! self.emit('JUMP_IF_TRUE', end)
! self.nextBlock()
! self.emit('POP_TOP')
! self.emit('LOAD_GLOBAL', 'AssertionError')
! if node.fail:
! self.visit(node.fail)
! self.emit('RAISE_VARARGS', 2)
! else:
! self.emit('RAISE_VARARGS', 1)
! self.nextBlock(end)
! self.emit('POP_TOP')
def visitRaise(self, node):
--- 708,730 ----
# XXX would be interesting to implement this via a
# transformation of the AST before this stage
! if __debug__:
! end = self.newBlock()
! self.set_lineno(node)
! # XXX AssertionError appears to be special case -- it is always
! # loaded as a global even if there is a local name. I guess this
! # is a sort of renaming op.
! self.nextBlock()
! self.visit(node.test)
! self.emit('JUMP_IF_TRUE', end)
! self.nextBlock()
! self.emit('POP_TOP')
! self.emit('LOAD_GLOBAL', 'AssertionError')
! if node.fail:
! self.visit(node.fail)
! self.emit('RAISE_VARARGS', 2)
! else:
! self.emit('RAISE_VARARGS', 1)
! self.nextBlock(end)
! self.emit('POP_TOP')
def visitRaise(self, node):
More information about the Python-checkins
mailing list