[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-03 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Yeah, this is not a bug as Serhiy points out. Regarding the error message, we 
are currently working on trying to unify the error messages in the the parser 
as much as we can but there is also no promise that they will match 100%.

Many grammar checks currently are done outside the parser (we mention it on  
PEP617) so I am not surprised that the old parser is ok with some invalid 
expressions and PyCF_ONLY_AST. This is one of the things we are trying to 
change with the new parser precisely.

I will close for now as "not a bug". Feel free to reopen if you think we missed 
something or if something was left to discuss.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-02 Thread Adam Williamson


Adam Williamson  added the comment:

Realized I forgot to give it, so in case it's important, the context here is 
the black test suite:

https://github.com/psf/black/issues/1441

that test suite has a file full of expressions that it expects to be able to 
parse this way (it uses `ast.parse()`, which in turn calls `compile()` with 
this flag). A bare (*starred) line is part of that file:

https://github.com/psf/black/blob/master/tests/data/expression.py#L149

and has been for as long as black has existed. Presumably if this isn't going 
to be fixed we'll need to adapt this black test file to test a starred 
expression in a 'valid' way, somehow.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-02 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is no promise that the parser can parse invalid Python code. I think 
there is no a bug here.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-02 Thread Christian Heimes


Change by Christian Heimes :


--
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-02 Thread Christian Heimes


Change by Christian Heimes :


--
nosy: +benjamin.peterson, brett.cannon, pablogsal, yselivanov
type:  -> behavior
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-02 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
nosy: +BTaskaya

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40848] compile() can compile a bare starred expression with `PyCF_ONLY_AST` flag with the old parser, but not the new one

2020-06-02 Thread Adam Williamson


New submission from Adam Williamson :

Not 100% sure this would be considered a bug, but it seems at least worth 
filing to check. This is a behaviour difference between the new parser and the 
old one. It's very easy to reproduce:

 sh-5.0# PYTHONOLDPARSER=1 python3
Python 3.9.0b1 (default, May 29 2020, 00:00:00) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from _ast import *
>>> compile("(*starred)", "", "exec", flags=PyCF_ONLY_AST)

>>> 
 sh-5.0# python3
Python 3.9.0b1 (default, May 29 2020, 00:00:00) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from _ast import *
>>> compile("(*starred)", "", "exec", flags=PyCF_ONLY_AST)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1
(*starred)
  ^
SyntaxError: invalid syntax

That is, you can compile() the expression "(*starred)" with PyCF_ONLY_AST flag 
set with the old parser, but not with the new one. Without PyCF_ONLY_AST you 
get a SyntaxError with both parsers, though a with the old parser, the error 
message is "can't use starred expression here", not "invalid syntax".

--
components: Interpreter Core
messages: 370620
nosy: adamwill
priority: normal
severity: normal
status: open
title: compile() can compile a bare starred expression with `PyCF_ONLY_AST` 
flag with the old parser, but not the new one
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com