Eric V. Smith <e...@trueblade.com> added the comment:

I assume the OP is using the stdlib parser module just to show what is a syntax 
error and what isn't. But most of the characters in the example strings aren't 
required, so it can be simplified.

Here is a simpler case demonstrating what I think the OP is trying to say.

This is not a syntax error:
>>> [*0<<1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable

(Ignore the type error, this shows that it's syntactically valid.)

But this is a syntax error:
>>> [*0<=1]
  File "<stdin>", line 1
    [*0<=1]
        ^
SyntaxError: invalid syntax

Both of these are treated the same way, as not syntax errors:
>>> f(*0==1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
>>> f(*0<=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined

Here's the above, using parser:

>>> import parser
>>> parser.expr("[*0<<1]")
<parser.st object at 0x7fa18d93a430>

>>> parser.expr("[*0<=1]")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    [*0<=1]
        ^
SyntaxError: invalid syntax

>>> parser.expr("f(*0<<1)")
<parser.st object at 0x7fa18d93a470>

>>> parser.expr("f(*0<=1)")
<parser.st object at 0x7fa18d93a410>

I'm not sure this is worth fixing. Maybe if someone can find where in the 
grammar this is caused, and understands the side effects of fixing it, it could 
be addressed. But I expect it to be non-trivial.

----------
components: +Interpreter Core
nosy: +eric.smith
versions: +Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36617>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to