Skip to content

format(mpf(3.14), '') raises ValueError #833

Description

@skirpichev

Reproducer:

>>> from mpmath import mpf
>>> format(mpf(3.14), '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sk/src/mpmath/mpmath/ctx_mp_python.py", line 359, in __format__
    return format_mpf(s._mpf_, format_spec)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/src/mpmath/mpmath/libmp/libmpf.py", line 1601, in format_mpf
    format_dict = read_format_spec(format_spec)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/src/mpmath/mpmath/libmp/libmpf.py", line 1465, in read_format_spec
    raise ValueError("Invalid format specifier '{}'".format(format_spec))
ValueError: Invalid format specifier ''

Instead, this should use default settings, like:

>>> format(3.14, '')
'3.14'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions