[New-bugs-announce] [issue44267] Wrong PEP 515 parsing in decimal module (both C and Python versions)
Sergey B Kirpichev
report at bugs.python.org
Sun May 30 00:12:10 EDT 2021
New submission from Sergey B Kirpichev <skirpichev at gmail.com>:
While working on issue44258 I discover that the decimal module doesn't follow specification in PEP 515: "The current proposal is to allow one underscore between digits, and after base specifiers in numeric literals." (c)
For example:
>>> float("1.1__1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: '1.1__1'
but
>>> from decimal import Decimal as C
>>> from _pydecimal import Decimal as P
>>> C("1.1__1")
Decimal('1.11')
>>> P("1.1__1")
Decimal('1.11')
Maybe this requirement could be relaxed in PEP, but it seems - this was already discussed (see Alternative Syntax section). Hence, I think this is a bug.
Patch for _pydecimal attached.
----------
components: Extension Modules, Library (Lib)
files: _pydecimal-pep515.diff
keywords: patch
messages: 394750
nosy: Sergey.Kirpichev
priority: normal
severity: normal
status: open
title: Wrong PEP 515 parsing in decimal module (both C and Python versions)
versions: Python 3.11
Added file: https://bugs.python.org/file50071/_pydecimal-pep515.diff
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44267>
_______________________________________
More information about the New-bugs-announce
mailing list