[Zope-Checkins] CVS: Zope2 - pycodegen.py:1.3
shane@digicool.com
shane@digicool.com
Fri, 8 Jun 2001 11:42:08 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/RestrictedPython/compiler
In directory korak.digicool.com:/tmp/cvs-serv19623/compiler
Modified Files:
pycodegen.py
Log Message:
Corrected a formerly obscure bug in the compiler module; Python Scripts
revealed it. "print" with output to a stream and a trailing comma needs to
end with a POP_TOP instruction.
--- Updated File pycodegen.py in package Zope2 --
--- pycodegen.py 2001/04/27 20:27:54 1.2
+++ pycodegen.py 2001/06/08 15:42:07 1.3
@@ -795,7 +795,7 @@
opcode = callfunc_opcode_info[have_star, have_dstar]
self.emit(opcode, kw << 8 | pos)
- def visitPrint(self, node):
+ def visitPrint(self, node, newline=0):
self.set_lineno(node)
if node.dest:
self.visit(node.dest)
@@ -806,11 +806,13 @@
if node.dest:
self.emit('ROT_TWO')
self.emit('PRINT_ITEM_TO')
+ if not newline:
+ self.emit('POP_TOP')
else:
self.emit('PRINT_ITEM')
def visitPrintnl(self, node):
- self.visitPrint(node)
+ self.visitPrint(node, 1)
if node.dest:
self.emit('PRINT_NEWLINE_TO')
else: