Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7267] format method: c presentation type broken

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 5, 2009, 8:22 AM

Post #1 of 6 (261 views)
Permalink
[issue7267] format method: c presentation type broken

New submission from Walter Dörwald <walter [at] livinglogic>:

The c presentation type in the new format method from PEP 3101 seems to
be broken:

Python 2.6.4 (r264:75706, Oct 27 2009, 15:18:04)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> u'{0:c}'.format(256)
u'\x00'

The PEP states:

'c' - Character. Converts the integer to the corresponding Unicode
character before printing, so I would have expected this to return
u'\u0100' instead of u'\x00'.

----------
components: Interpreter Core
messages: 94935
nosy: doerwalter
severity: normal
status: open
title: format method: c presentation type broken
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 5, 2009, 8:30 AM

Post #2 of 6 (253 views)
Permalink
[issue7267] format method: c presentation type broken [In reply to]

Eric Smith <eric [at] trueblade> added the comment:

I'll look at it.

----------
assignee: -> eric.smith
nosy: +eric.smith

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 6, 2009, 6:09 AM

Post #3 of 6 (247 views)
Permalink
[issue7267] format method: c presentation type broken [In reply to]

Eric Smith <eric [at] trueblade> added the comment:

This is a bug in the way ints and longs are formatted. They always do
the formatting as str, then convert to unicode. This works everywhere
except with the 'c' presentation type. I'm still trying to decide how
best to handle this.

----------
versions: +Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 6, 2009, 6:52 AM

Post #4 of 6 (244 views)
Permalink
[issue7267] format method: c presentation type broken [In reply to]

Walter Dörwald <walter [at] livinglogic> added the comment:

I'd say that a value >= 128 should generate a Unicode string (as the PEP
explicitely states that the value is a Unicode code point and not a byte
value).

However str.format() doesn't seem to support mixing str and unicode anyway:

>>> '{0}'.format(u'\u3042')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u3042' in
position 0: ordinal not in range(128)

so str.format() might raise an OverflowError for values >= 128 (or >= 256?)

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 10, 2009, 5:20 AM

Post #5 of 6 (229 views)
Permalink
[issue7267] format method: c presentation type broken [In reply to]

Eric Smith <eric [at] trueblade> added the comment:

> so str.format() might raise an OverflowError for values >= 128 (or >=
256?)

Maybe, but the issue you reported is in unicode.format() (not
str.format()), and I think that should be fixed. I'm trying to think of
how best to address it.

As for the second issue you raise (which I think is that str.format()
can't take a unicode argument), would you mind opening a separate issue
for this and assigning it to me? Thanks.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 10, 2009, 5:58 AM

Post #6 of 6 (236 views)
Permalink
[issue7267] format method: c presentation type broken [In reply to]

Walter Dörwald <walter [at] livinglogic> added the comment:

Done: issue 7300.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.