]> granicus.if.org Git - python/commitdiff
SF bug #497839: reindent chokes on empty first lines.
authorTim Peters <tim.peters@gmail.com>
Sun, 17 Feb 2002 07:03:05 +0000 (07:03 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 17 Feb 2002 07:03:05 +0000 (07:03 +0000)
Reindenter.run():  copy over initial all-whitespace lines (if any, and
after normalizing to remove trailing blanks and tabs).
Bugfix candidate.

Tools/scripts/reindent.py

index e646aed9c3ce08238bfc963128253f88f0cf88cc..21c553b7f805f25fe87cfe03a1c909a88314d3e8 100644 (file)
@@ -157,6 +157,10 @@ class Reindenter:
         have2want = {}
         # Program after transformation.
         after = self.after = []
+        # Copy over initial empty lines -- there's nothing to do until
+        # we see a line with *something* on it.
+        i = stats[0][0]
+        after.extend(lines[1:i])
         for i in range(len(stats)-1):
             thisstmt, thislevel = stats[i]
             nextstmt = stats[i+1][0]