Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid conversion specification" error for align '=' value in format spec #505

Open
skirpichev opened this issue Aug 6, 2024 · 1 comment

Comments

@skirpichev
Copy link
Contributor

skirpichev commented Aug 6, 2024

>>> from gmpy2 import *
>>> f"{mpfr('123.456'):=.5g}"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Invalid conversion specification
>>> f"{float(mpfr('123.456')):=.5g}"  # works for python floats
'123.46'

I think we should be compatible with python floats here, meaning '=' is: "Forces the padding to be placed after the sign (if any) but before the digits. This is used for printing fields in the form ‘+000000120’. This alignment option is only valid for numeric types. It becomes the default for numbers when ‘0’ immediately precedes the field width."

@skirpichev skirpichev changed the title Invalid conversion specification (ValueError) for align '=' value in format spec "Invalid conversion specification" error for align '=' value in format spec Aug 6, 2024
@casevh
Copy link
Collaborator

casevh commented Sep 5, 2024

I agree that it is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants