[pypy-svn] r66338 - in pypy/branch/parser-compiler/pypy/interpreter/astcompiler: . test

benjamin at codespeak.net benjamin at codespeak.net
Sat Jul 18 00:04:06 CEST 2009


Author: benjamin
Date: Sat Jul 18 00:04:05 2009
New Revision: 66338

Modified:
   pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py
   pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py
Log:
fix while loops with a constant false test

Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py	(original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py	Sat Jul 18 00:04:05 2009
@@ -436,7 +436,7 @@
         test_constant = misc.expr_constant(self.space, wh.test)
         if test_constant == misc.CONST_FALSE:
             if wh.orelse:
-                self.visit_sequence(orelse)
+                self.visit_sequence(wh.orelse)
         else:
             end = self.new_block()
             if test_constant == misc.CONST_NOT_CONST:

Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py	(original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py	Sat Jul 18 00:04:05 2009
@@ -434,6 +434,12 @@
                 comments[:0] = [comment]
                 comment = ''
         """, 'comments', ['# foo', 42]
+        yield self.simple_test, """
+             while 0:
+                 pass
+             else:
+                 x = 1
+        """, "x", 1
 
     def test_return_lineno(self):
         # the point of this test is to check that there is no code associated



More information about the Pypy-commit mailing list