Issue32894
Created on 2018-02-21 12:20 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 17426 | merged | BTaskaya, 2019-12-01 18:38 | |
| Messages (3) | |||
|---|---|---|---|
| msg312492 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-02-21 12:20 | |
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.
|
|||
| msg366343 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2020-04-13 22:51 | |
New changeset 258f5179f9494189e6a80311c86981d2a88ba9d6 by Batuhan Taşkaya in branch 'master': bpo-32894: Support unparsing of infinity numbers in ast_unparser.c (GH-17426) https://github.com/python/cpython/commit/258f5179f9494189e6a80311c86981d2a88ba9d6 |
|||
| msg366347 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2020-04-13 22:55 | |
It seems like the fix works as expected:
>>> from __future__ import annotations
>>> def f(x: A[1e1000, 1e1000j]): pass
...
>>> f.__annotations__
{'x': 'A[1e309, 1e309j]'}
>>> A=list
>>> eval(f.__annotations__['x'])
list[inf, infj]
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:58 | admin | set | github: 77075 |
| 2020-04-13 22:55:44 | vstinner | set | status: open -> closed resolution: fixed messages: + msg366347 stage: patch review -> resolved |
| 2020-04-13 22:51:37 | vstinner | set | nosy:
+ vstinner messages: + msg366343 |
| 2019-12-01 18:38:27 | BTaskaya | set | keywords:
+ patch stage: patch review pull_requests: + pull_request16905 |
| 2019-12-01 18:35:53 | BTaskaya | set | nosy:
+ BTaskaya |
| 2019-12-01 18:35:44 | BTaskaya | set | versions: + Python 3.9 |
| 2018-11-21 14:23:10 | mark.dickinson | set | nosy:
+ mark.dickinson |
| 2018-11-21 08:33:49 | serhiy.storchaka | set | assignee: serhiy.storchaka |
| 2018-02-21 12:20:59 | serhiy.storchaka | create | |
