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

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

Closed
mark-summerfield mannequin opened this issue Jun 19, 2008 · 3 comments
Closed

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

mark-summerfield mannequin opened this issue Jun 19, 2008 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@mark-summerfield
Copy link
Mannequin

mark-summerfield mannequin commented Jun 19, 2008

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']

@mark-summerfield
Copy link
Mannequin Author

mark-summerfield mannequin commented Jun 19, 2008

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?

@mark-summerfield mark-summerfield mannequin added the type-bug An unexpected behavior, bug, or error label Jun 19, 2008
@ericvsmith
Copy link
Member

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

@ericvsmith ericvsmith added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jun 19, 2008
@ericvsmith
Copy link
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]

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant