]> granicus.if.org Git - python/commitdiff
From: "Tim Peters" <tim_one@msn.com>
authorGuido van Rossum <guido@python.org>
Tue, 9 Jun 1998 19:02:21 +0000 (19:02 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 9 Jun 1998 19:02:21 +0000 (19:02 +0000)
The 1.5.1 tabnanny.py suffers an assert error if fed a script whose last
line is both indented and lacks a newline:

if 1:
    print 'oh fudge' # no newline here:

The attached version repairs that.

Lib/tabnanny.py
Tools/idle/tabnanny.py
Tools/scripts/tabnanny.py

index 6dca8af487bcf498f1243cee4ca4f01c433e9cca..a9bd9dc45562980c2a63f4497d92e80c2a6048e6 100755 (executable)
@@ -2,9 +2,9 @@
 
 """The Tab Nanny despises ambiguous indentation.  She knows no mercy."""
 
-# Released to the public domain, by Tim Peters, 6 April 1998.
+# Released to the public domain, by Tim Peters, 15 April 1998.
 
-__version__ = "4"
+__version__ = "5"
 
 import os
 import sys
@@ -270,7 +270,13 @@ if hasattr(tokenize, 'NL'):
          # that when the run of DEDENTs ends, the indentation of the
          # program statement (or ENDMARKER) that triggered the run is
          # equal to what's left at the top of the indents stack
-         assert check_equal  # else no earlier NEWLINE, or an earlier INDENT
+
+         # Ouch!  This assert triggers if the last line of the source
+         # is indented *and* lacks a newline -- then DEDENTs pop out
+         # of thin air.
+         # assert check_equal  # else no earlier NEWLINE, or an earlier INDENT
+         check_equal = 1
+
          del indents[-1]
 
      elif check_equal and type not in JUNK:
index 6dca8af487bcf498f1243cee4ca4f01c433e9cca..a9bd9dc45562980c2a63f4497d92e80c2a6048e6 100755 (executable)
@@ -2,9 +2,9 @@
 
 """The Tab Nanny despises ambiguous indentation.  She knows no mercy."""
 
-# Released to the public domain, by Tim Peters, 6 April 1998.
+# Released to the public domain, by Tim Peters, 15 April 1998.
 
-__version__ = "4"
+__version__ = "5"
 
 import os
 import sys
@@ -270,7 +270,13 @@ if hasattr(tokenize, 'NL'):
          # that when the run of DEDENTs ends, the indentation of the
          # program statement (or ENDMARKER) that triggered the run is
          # equal to what's left at the top of the indents stack
-         assert check_equal  # else no earlier NEWLINE, or an earlier INDENT
+
+         # Ouch!  This assert triggers if the last line of the source
+         # is indented *and* lacks a newline -- then DEDENTs pop out
+         # of thin air.
+         # assert check_equal  # else no earlier NEWLINE, or an earlier INDENT
+         check_equal = 1
+
          del indents[-1]
 
      elif check_equal and type not in JUNK:
index 6dca8af487bcf498f1243cee4ca4f01c433e9cca..a9bd9dc45562980c2a63f4497d92e80c2a6048e6 100755 (executable)
@@ -2,9 +2,9 @@
 
 """The Tab Nanny despises ambiguous indentation.  She knows no mercy."""
 
-# Released to the public domain, by Tim Peters, 6 April 1998.
+# Released to the public domain, by Tim Peters, 15 April 1998.
 
-__version__ = "4"
+__version__ = "5"
 
 import os
 import sys
@@ -270,7 +270,13 @@ if hasattr(tokenize, 'NL'):
          # that when the run of DEDENTs ends, the indentation of the
          # program statement (or ENDMARKER) that triggered the run is
          # equal to what's left at the top of the indents stack
-         assert check_equal  # else no earlier NEWLINE, or an earlier INDENT
+
+         # Ouch!  This assert triggers if the last line of the source
+         # is indented *and* lacks a newline -- then DEDENTs pop out
+         # of thin air.
+         # assert check_equal  # else no earlier NEWLINE, or an earlier INDENT
+         check_equal = 1
+
          del indents[-1]
 
      elif check_equal and type not in JUNK: