[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.11 -Python 3.9

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread miss-islington


miss-islington  added the comment:


New changeset bea3f42bb7c360921f864949ef7472a7ecb02cd3 by Miss Islington (bot) 
in branch '3.10':
bpo-46289: Make conversion of FormattedValue not optional on ASDL (GH-30467)
https://github.com/python/cpython/commit/bea3f42bb7c360921f864949ef7472a7ecb02cd3


--

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28672
pull_request: https://github.com/python/cpython/pull/30469

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I would say yes, for consistency. It doesn't have any effects on user code that 
I am aware

--

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

Should we backport this?

On Sat, Jan 8, 2022, 12:05 AM miss-islington  wrote:

>
> miss-islington  added the
> comment:
>
>
> New changeset d382f7ee0b98e4ab6ade9384268f25c06be462ad by Batuhan Taskaya
> in branch 'main':
> bpo-46289: Make conversion of FormattedValue not optional on ASDL
> (GH-30467)
>
> https://github.com/python/cpython/commit/d382f7ee0b98e4ab6ade9384268f25c06be462ad
>
>
> --
> nosy: +miss-islington
>
> ___
> Python tracker 
> 
> ___
>

--
nosy: +Batuhan Taskaya

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread miss-islington


miss-islington  added the comment:


New changeset d382f7ee0b98e4ab6ade9384268f25c06be462ad by Batuhan Taskaya in 
branch 'main':
bpo-46289: Make conversion of FormattedValue not optional on ASDL (GH-30467)
https://github.com/python/cpython/commit/d382f7ee0b98e4ab6ade9384268f25c06be462ad


--
nosy: +miss-islington

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +28670
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30467

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I think A is the best option

--

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Lysandros Nikolaou


Lysandros Nikolaou  added the comment:

I agree that A is probably the way to go.

--

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

ASDL technically allows it to be None though neither compiler nor ast.unparse 
can work with it at this moment. 

> FormattedValue(expr value, int? conversion, expr? format_spec)
https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Parser/Python.asdl#L78

>>> import ast
>>> tree = ast.parse("f'{x + 1}'")
>>> tree.body[0].value.values[0].conversion = None
>>> compile(tree, "", "exec")
Traceback (most recent call last):
  File "", line 1, in 
SystemError: Unrecognized conversion character 0

We can either:
A) change ASDL to reflect it is an integer (since it always has been treated 
that way)
B) Support this on both the compiler as well as in the ast.unparse

I'd say A, since this was always broken. @pablogsal @lys.nikolaou WDYT?

--

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +BTaskaya

___
Python tracker 

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



[issue46289] AST: FomattedValue conversion's default value should be -1

2022-01-07 Thread Anh71me


New submission from Anh71me :

An unexpected behavior lookup:

```python
>>> ast.FormattedValue(ast.Str('ss')).conversion
>>> ast.unparse(ast.FormattedValue(ast.Str('ss')))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.9/ast.py", line 1564, in unparse
return unparser.visit(ast_obj)
  File "/usr/local/lib/python3.9/ast.py", line 801, in visit
self.traverse(node)
  File "/usr/local/lib/python3.9/ast.py", line 795, in traverse
super().visit(node)
  File "/usr/local/lib/python3.9/ast.py", line 407, in visit
return visitor(node)
  File "/usr/local/lib/python3.9/ast.py", line 1153, in visit_FormattedValue
self._fstring_FormattedValue(node, self.buffer_writer)
  File "/usr/local/lib/python3.9/ast.py", line 1178, in _fstring_FormattedValue
conversion = chr(node.conversion)
TypeError: an integer is required (got type NoneType)
>>> ast.unparse(ast.FormattedValue(ast.Str('ss'), -1))
'f"{\'ss\'}"'
```

ast.FormattedValue conversion's default value is expected to be -1 but not None

See: https://docs.python.org/3/library/ast.html#ast.FormattedValue

Other:

If certainly, it's also a bug on typeshed.

--
components: Parser
messages: 409955
nosy: iyume, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: AST: FomattedValue conversion's default value should be -1
type: behavior
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