[issue41659] PEG discrepancy on 'if {x} {a}: pass'
Guido van Rossum
report at bugs.python.org
Fri Aug 28 17:43:15 EDT 2020
New submission from Guido van Rossum <guido at python.org>:
I just noticed a subtle discrepancy between the old parser and the PEG parser.
Consider this syntax error:
```
if x {a}: pass
```
The old parser places the caret at the '{':
```
$ python3.8 -c 'if x { a } : pass'
File "<string>", line 1
if x { a } : pass
^
SyntaxError: invalid syntax
```
The PEG parser puts it at 'a':
```
$ python3.10 -c 'if x { a } : pass'
File "<string>", line 1
if x { a } : pass
^
SyntaxError: invalid syntax
```
I don't think we should put much effort into fixing it -- it's just a curiosity. I suspect it's got to do with some lookahead.
----------
assignee: lys.nikolaou
messages: 376048
nosy: gvanrossum, lys.nikolaou
priority: low
severity: normal
stage: needs patch
status: open
title: PEG discrepancy on 'if {x} {a}: pass'
type: behavior
versions: Python 3.10, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41659>
_______________________________________
More information about the Python-bugs-list
mailing list