Message 405861 - Python tracker (original) (raw)

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 "", line 1, in 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