[Python-checkins] r42947 - python/trunk/Tools/compiler/astgen.py

tim.peters python-checkins at python.org
Thu Mar 9 23:31:48 CET 2006


Author: tim.peters
Date: Thu Mar  9 23:31:45 2006
New Revision: 42947

Modified:
   python/trunk/Tools/compiler/astgen.py
Log:
NodeInfo.__gen_init():  Fiddle so that reindent.py is
happy with the output as-is.  This incidentally also
gets rid of "an extra" blank line at the end of the output
block that probably wasn't intended (although it doesn't
matter one way or the other).


Modified: python/trunk/Tools/compiler/astgen.py
==============================================================================
--- python/trunk/Tools/compiler/astgen.py	(original)
+++ python/trunk/Tools/compiler/astgen.py	Thu Mar  9 23:31:45 2006
@@ -113,8 +113,11 @@
             for name in self.argnames:
                 print >> buf, "        self.%s = %s" % (name, name)
         print >> buf, "        self.lineno = lineno"
-        if self.init:
-            print >> buf, "".join(["    " + line for line in self.init])
+        # Copy the lines in self.init, indented four spaces.  The rstrip()
+        # business is to get rid of the four spaces if line happens to be
+        # empty, so that reindent.py is happy with the output.
+        for line in self.init:
+            print >> buf, ("    " + line).rstrip()
 
     def _gen_getChildren(self, buf):
         print >> buf, "    def getChildren(self):"


More information about the Python-checkins mailing list