Mailing List Archive

python -t gets confused?
The tab/space checking code in the tokenizer seems to get confused
by the recently checked in test_pyexpat.py

With python -t or -tt, there are inconsistency reports at places where
there doesn't seem to be one. (tabnanny seems to be confused too, btw :)

./python -tt Lib/test/test_pyexpat.py
File "Lib/test/test_pyexpat.py", line 13
print 'Start element:\n\t', name, attrs
^
SyntaxError: inconsistent use of tabs and spaces in indentation

Thus, "make test" reports a failure on test_pyexpat due to a syntax error,
instead of a missing optional feature (expat not compiled in).

I'm not an expert of the tokenizer code, so someone might want to look
at it and tell us what's going on. Without -t or -tt, the code runs fine.

--
Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252
RE: python -t gets confused? [ In reply to ]
[Vladimir Marangozov]
> The tab/space checking code in the tokenizer seems to get confused
> by the recently checked in test_pyexpat.py
>
> With python -t or -tt, there are inconsistency reports at places where
> there doesn't seem to be one. (tabnanny seems to be confused too, btw :)

They're not confused, they're simply reporting that the indentation is
screwed up in this file -- which it is. It mixes tabs and spaces in
ambiguous ways.

> ...
> I'm not an expert of the tokenizer code, so someone might want to look
> at it and tell us what's going on. Without -t or -tt, the code runs fine.

If you set your editor to believe that tab chars are 4 columns (as my
Windows editor does), the problem (well, problems -- many lines are flawed)
will be obvious. It runs anyway because tab=8 is hardcoded in the Python
parser.

Quickest fix is for someone at CNRI to just run this thru one of the Unix
detabifier programs.