Message286929
| Author |
martin.panter |
| Recipients |
docs@python, marco.buttu, martin.panter, paul.moore, steve.dower, terry.reedy, tim.golden, xiang.zhang, zach.ware |
| Date |
2017年02月04日.08:33:17 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1486197197.55.0.824286912155.issue29387@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|