◐ Shell
clean mode source ↗

Message 170551 - Python tracker

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