[New-bugs-announce] [issue46091] IndendationError from multi-line indented statements

Jeremy report at bugs.python.org
Wed Dec 15 18:06:30 EST 2021


New submission from Jeremy <ucodery at gmail.com>:

At some point in 3.9 Python appears to have stopped accepting source that starts with an indent, then a '\', then the indented statement. From the lexical analysis [1] "Indentation cannot be split over multiple physical lines using backslashes; the whitespace up to the first backslash determines the indentation."

Running the attached program under 3.8.12 I get:
```
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
```

But running under 3.10.0 I get:
```
  File "/Users/jeremyp/tmp/nodent.py", line 3
    """Print a Fibonacci series up to n."""
    ^
IndentationError: expected an indented block after function definition on line 1
```

Running under 3.9.9 also gives an IndentationError, both with and without -X oldparser. So this doesn't seem directly related to the new parser, but seems likely it is fall out from the general grammar restructuring.

IMHO it isn't a particularly nice feature for the language to have. Especially since not all lines like '    \' behave the same. But it was there and documented for many years, so should probably be put back. Does a core developer agree? That the implementation is not following the spec?

[1]: https://docs.python.org/3/reference/lexical_analysis.html#indentation

----------
components: Parser
files: nodent.py
messages: 408651
nosy: lys.nikolaou, pablogsal, ucodery
priority: normal
severity: normal
status: open
title: IndendationError from multi-line indented statements
versions: Python 3.10, Python 3.11, Python 3.9
Added file: https://bugs.python.org/file50496/nodent.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46091>
_______________________________________


More information about the New-bugs-announce mailing list