Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
c.f.
>>>format(float(Fraction(1, 3)), '.016f') '0.3333333333333333'Looking on docs, I think that float formatting better conforms to the specification.
Similar issue is valid for the width:
>>>format(float(Fraction(1, 3)), '0030.016f') '0000000000000.3333333333333333'>>>format(Fraction(1, 3), '0030.016f') Traceback (mostrecentcalllast): File"<python-input-3>", line1, in<module>format(Fraction(1, 3), '0030.016f') ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/local/lib/python3.13/fractions.py", line577, in__format__raiseValueError( ...<2lines>... ) ValueError: Invalidformatspecifier'0030.016f'forobjectof type 'Fraction'CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-130662: accept leading zeros in precision/width for Fraction's formatting #130663
- gh-130662: refine width/precision specification in format-spec #130717
- gh-130662: accept leading zeros in precision/width for Decimal's formatting #132549
- [3.14] gh-130662: Accept leading zeros in precision/width for Fraction's formatting (GH-130663) #135026
- [3.14] gh-130662: Accept leading zeros in precision/width for Fraction's formatting (GH-130663) #136361
- [3.14] gh-130662: Accept leading zeros in precision/width for Decimal's formatting (GH-132549) #136362
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error