This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong offset with IndentationError ("expected an indented block")
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: blueyed, cheryl.sabella, martin.panter
Priority: normal Keywords:

Created on 2017-09-16 20:58 by blueyed, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg302354 - (view) Author: daniel hahler (blueyed) * Date: 2017-09-16 20:58
Given the following file `t-expected-indent.py`:
```
if 1:
foo
```

python t-expected-indent.py reports:

```
  File "t-expected-indent.py", line 2
    foo
      ^
IndentationError: expected an indented block
```

However, it should get reported for column 1 instead of 3.
msg302356 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-09-16 23:11
Some relevant info I wrote in Issue 25677:

‘The caret points to the character _before_ offset. . . . In some cases (e.g. the line “1 +”), the offset is the string index _after_ the error. But in the case of “1;1 + 1 = 2”, offset is the index where the error (statement) begins.’

In this case it looks like the offset is of the end of the first word on the line that has the wrong indentation. The caret is positioned one position back, to point at the last character of that word.
msg338574 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-03-22 00:00
I've retested this under 3.8 and the caret is now positioned at the first character in the line, therefore I'm closing this issue as resolved.
History
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75676
2019-03-22 00:00:42cheryl.sabellasetstatus: open -> closed

versions: + Python 3.8, - Python 3.7
nosy: + cheryl.sabella

messages: + msg338574
resolution: works for me
stage: resolved
2017-09-16 23:11:51martin.pantersetnosy: + martin.panter
messages: + msg302356
2017-09-16 20:58:29blueyedcreate