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

Anh71me report at bugs.python.org
Fri Jan 7 04:40:18 EST 2022

New submission from Anh71me <iyumelive at gmail.com>:

An unexpected behavior lookup:

>>> ast.FormattedValue(ast.Str('ss')).conversion
>>> ast.unparse(ast.FormattedValue(ast.Str('ss')))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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
  File "/usr/local/lib/python3.9/ast.py", line 795, in traverse
  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))

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


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 <report at bugs.python.org>

More information about the New-bugs-announce mailing list