Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

format(Fraction(1, 3), '.016f') raises ValueError #130662

Closed
Labels
3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@skirpichev

Description

@skirpichev

Bug report

Bug description:

c.f.

>>>format(float(Fraction(1,3)),'.016f')'0.3333333333333333'

Looking ondocs, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp