-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed as not planned
Closed as not planned
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirinvalidtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
from decimal import Decimal, getcontext
EMIN = getcontext().Emin
EMAX = getcontext().Emax
exprs = (
"Decimal(f'1E+{EMAX}')",
"Decimal(f'1E+{EMAX+10}')",
# "Decimal(f'{10 ** (EMAX+10)}')",
"Decimal(f'1E+{EMAX+10}') / 10",
"Decimal(f'1E{EMIN}')",
"Decimal(f'1E{EMIN-10}')",
"Decimal(f'1E{EMIN-10}') * 10",
)
for expr in exprs:
print(expr)
try:
print(eval(expr))
except Exception as e:
print(e)
print()Output:
Decimal(f'1E+{EMAX}')
1E+999999
Decimal(f'1E+{EMAX+10}')
1E+1000009
Decimal(f'1E+{EMAX+10}') / 10
[<class 'decimal.Overflow'>]
Decimal(f'1E{EMIN}')
1E-999999
Decimal(f'1E{EMIN-10}')
1E-1000009
Decimal(f'1E{EMIN-10}') * 10
1.0E-1000008
CPython versions tested on:
3.15, 3.14, 3.13, 3.12, 3.11, 3.10, 3.9
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirinvalidtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error