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

Wrong sign placement in PyUnicode_FromFormat #95504

Closed
Assignees
methane
Labels
type-bugAn unexpected behavior, bug, or error
@philg314

Description

@philg314

Bug report

When specifying width or precision with a negative number the sign ignores that and sticks to the number.
Width specifies the minimum output width, so if the zero flag is set the sign should be the first character of the width padding, if the zero flag is not set the last character of the padding.
Precision specifies the number of digits, so the sign should be placed before precision count digits.

PyUnicode_FromFormat("%05d",-123);//   "0-123" should be   "-0123"PyUnicode_FromFormat("%.5d",-123);//   "0-123" should be  "-00123"PyUnicode_FromFormat("%7.5d",-123);// "  0-123" should be " -00123"PyUnicode_FromFormat("%07.5d",-123);// "000-123" should be "-000123"

Your environment

  • CPython versions tested on: main branch

Metadata

Metadata

Assignees

Labels

type-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