[New-bugs-announce] [issue15951] string.Formatter returns str for empty unicode template

Aleksey Sivokon report at bugs.python.org
Sun Sep 16 13:55:56 CEST 2012


New submission from Aleksey Sivokon:

Expected behavior of string.Formatter() is to return unicode strings for unicode templates, and "byte" strings for str templates. Which is exactly what it does, with one frustrating exception: for empty unicode string it returns byte str. Test follows:

import string
template = u""
result = string.Formatter().format(template)
assert isinstance(result, unicode)
# AssertionError

----------
components: Library (Lib)
messages: 170551
nosy: Aleksey.Sivokon
priority: normal
severity: normal
status: open
title: string.Formatter returns str for empty unicode template
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15951>
_______________________________________


More information about the New-bugs-announce mailing list