]> granicus.if.org Git - python/commitdiff
NodeInfo.__gen_init(): Fiddle so that reindent.py is
authorTim Peters <tim.peters@gmail.com>
Thu, 9 Mar 2006 22:31:45 +0000 (22:31 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 9 Mar 2006 22:31:45 +0000 (22:31 +0000)
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).

Tools/compiler/astgen.py

index e6aa35030d492249a86510bcccd407667d3e6bdc..59b98f2b0a186f562fbe729ea9b35d19dc3ac6d4 100644 (file)
@@ -113,8 +113,11 @@ class NodeInfo:
             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):"