[New-bugs-announce] [issue32894] AST unparsing of infinity numbers

Serhiy Storchaka report at bugs.python.org
Wed Feb 21 07:20:59 EST 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

AST unparsing of infinity numbers produces a string which can't be evaluated because inf and infj are not builtins.

>>> from __future__ import annotations
>>> def f(x: A[1e1000, 1e1000j]): pass
... 
>>> f.__annotations__
{'x': 'A[(inf, infj)]'}

See how this problem is handled in Tools/parser/unparse.py.

There is similar problem with NaN. NaN can't be a result of parsing Python sources, but it can be injected manually in AST, and it can be a result of third-party AST optimizer.

----------
components: Interpreter Core
messages: 312492
nosy: gvanrossum, lukasz.langa, serhiy.storchaka
priority: normal
severity: normal
status: open
title: AST unparsing of infinity numbers
type: behavior
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32894>
_______________________________________


More information about the New-bugs-announce mailing list