New submission from Serhiy Storchaka <[email protected]>:
The C implementation supports both formats "n" and "N". The Python
implementation only supports format "n".
>>> from decimal import Decimal
>>> format(Decimal('1e100'), 'n')
'1e+100'
>>> format(Decimal('1e100'), 'N')
'1E+100'
>>> from _pydecimal import Decimal
>>> format(Decimal('1e100'), 'n')
'1e+100'
>>> format(Decimal('1e100'), 'N')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/_pydecimal.py", line 3766, in __format__
spec = _parse_format_specifier(specifier, _localeconv=_localeconv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/serhiy/py/cpython/Lib/_pydecimal.py", line 6194, in
_parse_format_specifier
raise ValueError("Invalid format specifier: " + format_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Invalid format specifier: N
----------
components: Library (Lib)
messages: 405861
nosy: facundobatista, mark.dickinson, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: The Python implementation of Decimal does not support the "N" format
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45739>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com