[Python-Dev] SyntaxError patches

Ka-Ping Yee ping@lfw.org
Wed, 12 Jul 2000 01:40:55 -0700 (PDT)


On Wed, 12 Jul 2000, Peter Funk wrote:
> ###
> class Foo(Bar):
>      def pasted_method(self, ....)
> #---^ note this additional blank here (resulting in a 5 space indent).
> 	 # ...a screenful of indented code snipped here...
>     def another_method(self, baz, bang):
> #--------------------------------------^ 
> # Python 1.5.2 barfs here with "SyntaxError: invalid token"
> ###
> 
> This is not very intuitive and hard to see.  The first time I stumbled 
> about this it has taken me quite some time to discover my mistake.

Gee.  Well, with the SyntaxError patch, at least the error message
is much better (even though the arrow still points to the wrong place):

    >>> class foo:
    ...     def foo(self):
    ...         pass
    ...    def foo(bar):
      File "<stdin>", line 4
        def foo(bar):
                    ^
    SyntaxError: dedent does not match any outer indentation level

Not sure why the arrow points there... i would have expected it to
point at the beginning of the line, since it did successfully detect
that the indentation was wrong.  Maybe i'll investigate.


-- ?!ng