Skip to content

str.format("{0:n}") poss. bug with setlocale() #47390

Closed

Description

@mark-summerfield
BPO 3140
Nosy @ericvsmith, @mark-summerfield

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/ericvsmith'
closed_at = <Date 2008-06-24.11:21:37.894>
created_at = <Date 2008-06-19.13:02:12.924>
labels = ['interpreter-core', 'type-bug']
title = 'str.format("{0:n}") poss. bug with setlocale()'
updated_at = <Date 2008-06-24.11:21:37.854>
user = 'https://github.com/mark-summerfield'

bugs.python.org fields:

activity = <Date 2008-06-24.11:21:37.854>
actor = 'eric.smith'
assignee = 'eric.smith'
closed = True
closed_date = <Date 2008-06-24.11:21:37.894>
closer = 'eric.smith'
components = ['Interpreter Core']
creation = <Date 2008-06-19.13:02:12.924>
creator = 'mark'
dependencies = []
files = []
hgrepos = []
issue_num = 3140
keywords = []
message_count = 3.0
messages = ['68403', '68408', '68676']
nosy_count = 3.0
nosy_names = ['talin', 'eric.smith', 'mark']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue3140'
versions = ['Python 2.6', 'Python 3.0']

Activity

  1. mark-summerfield commented on Jun 19, 2008

    mark-summerfieldmannequin
    MannequinAuthor

    Python 30b1

    >>> import locale
    >>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
    'en_US.UTF-8'
    >>> for x in
    (1234,12345,123456,1234567,12345678,123456789,1234567890,12345678900):
    	print("[{0:>20n}]".format(x))

    [ 1,234]
    [ 12,345]
    [ 123,456]
    [ 1,234,567]
    [ 12,345,678]
    [ 123,456,789]
    [ 1,234,567,890]
    [ 12,345,678,900]

    I expected that the commas would not increase the width, but maybe this
    was the intended behaviour?

  2. ericvsmith commented on Jun 19, 2008

    @ericvsmith
    Member

    I'd say that's a bug. I'll look at it.

  3. ericvsmith commented on Jun 24, 2008

    @ericvsmith
    Member

    Fixed in r64499 (trunk) and r64500 (py3k).

    I now get:
    >>> import locale
    >>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
    'en_US.UTF-8'
    >>> for x in
    (123,1234,12345,123456,1234567,12345678,123456789,1234567890,12345678900):
    ...  print("[{0:>20n}]".format(x))
    ... 
    [                 123]
    [               1,234]
    [              12,345]
    [             123,456]
    [           1,234,567]
    [          12,345,678]
    [         123,456,789]
    [       1,234,567,890]
    [      12,345,678,900]

    and:

    >>> for x in
    (123,1234,12345,123456,1234567,12345678,123456789,1234567890,12345678900):
    ...  print("[{0:>10n}]".format(x))
    ... 
    [       123]
    [     1,234]
    [    12,345]
    [   123,456]
    [ 1,234,567]
    [12,345,678]
    [123,456,789]
    [1,234,567,890]
    [12,345,678,900]
  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions