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

float format specifier throws on int, unlike in cpython. #838

Open
mickp opened this issue Jan 13, 2024 · 1 comment
Open

float format specifier throws on int, unlike in cpython. #838

mickp opened this issue Jan 13, 2024 · 1 comment

Comments

@mickp
Copy link
Contributor

mickp commented Jan 13, 2024

Description

If an int is passed to a float format specifier, IronPython treats the float specifier as an int specifier and throws, whereas cpython treats the int as a float.

Steps to Reproduce

>>> "{:.3f}".format(1)

Expected behavior:
Verified in cpython 2.7.1.7

>>> "{:.3f}".format(1)
'1.000'
>>>

Actual behavior: [What actually happened]

>>> "{:.3f}".format(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Precision not allowed in integer format specifier
>>>

Versions

IronPython 2.7.12 (2.7.12.1000)
[.NETFramework,Version=v4.5 on .NET Framework 4.8.9195.0 (64-bit)]

@slozier
Copy link
Contributor

slozier commented Jan 13, 2024

I the fix is basically IronLanguages/ironpython3#1643 if anyone feels like backporting.

mickp pushed a commit to mickp/ironpython2 that referenced this issue Feb 3, 2024
slozier pushed a commit that referenced this issue Feb 5, 2024
Co-authored-by: Mick Phillips <mick.phillips@berkeleylights.com>
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