[New-bugs-announce] [issue40847] New parser considers empty line following a backslash to be a syntax error, old parser didn't

Adam Williamson report at bugs.python.org
Tue Jun 2 15:03:34 EDT 2020


New submission from Adam Williamson <awilliam at redhat.com>:

While debugging issues with the black test suite in Python 3.9, I found one which black upstream says is a Cpython issue, so I'm filing it here.

Reproduction is very easy. Just use this four-line tester:

    print("hello, world")
    \

    print("hello, world 2")

with that saved as `test.py`, check the results:

    <mock-chroot> sh-5.0# PYTHONOLDPARSER=1 python3 test.py
    hello, world
    hello, world 2
    <mock-chroot> sh-5.0# python3 test.py
      File "/builddir/build/BUILD/black-19.10b0/test.py", line 3
        
        ^
    SyntaxError: invalid syntax

The reason black has this test (well, a similar test - in black's test, the file *starts* with the backslash then the empty line, but the result is the same) is covered in https://github.com/psf/black/issues/922 and https://github.com/psf/black/pull/948 .

----------
components: Interpreter Core
messages: 370618
nosy: adamwill
priority: normal
severity: normal
status: open
title: New parser considers empty line following a backslash to be a syntax error, old parser didn't
type: behavior
versions: Python 3.9

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


More information about the New-bugs-announce mailing list