Commit 0d632d87 authored by Stefan Behnel's avatar Stefan Behnel

enable % formatting of byte strings by providing a __str__() special method that encodes to unicode

parent e6a1d09b
......@@ -592,7 +592,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
includes = []
for filename in env.include_files:
# fake decoding of filenames to their original byte sequence
code.putln('#include "%s"' % filename.as_unicode())
code.putln('#include "%s"' % filename)
def generate_filename_table(self, code):
code.putln("")
......
......@@ -89,9 +89,9 @@ class BytesLiteral(_bytes):
def utf8encode(self):
assert False, "this is not a unicode string: %r" % self
def as_unicode(self):
"""Returns a Unicode sequence that matches the byte sequence
of this literal.
def __str__(self):
"""Fake-decode the byte string to unicode to support %
formatting of unicode strings.
"""
return self.decode('ISO-8859-1')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment