Martin Panter added the comment:

Marco: I agree “Python reports an error” would have been simpler. That is what 
I meant to say. Anyway, perhaps we should put

Python raises :exc:`IndentationError` if mixed tabs and spaces are causing 
problems in leading whitespace.

In general, the exception seems to be IndentationError. TabError is a subclass, 
but is not raised in all circumstances. It seems the compiler assumes a 
particular tab model, so the exact exception depends on the amount of tabs and 
spaces:

>>> exec("if True:\n" + " "*8 + "1\n" "\t2\n")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3
    2
    ^
TabError: inconsistent use of tabs and spaces in indentation
>>> exec("if True:\n" + " "*9 + "1\n" "\t2\n")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3
    2
    ^
IndentationError: unindent does not match any outer indentation level

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29387>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to