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): ...@@ -592,7 +592,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
includes = [] includes = []
for filename in env.include_files: for filename in env.include_files:
# fake decoding of filenames to their original byte sequence # 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): def generate_filename_table(self, code):
code.putln("") code.putln("")
......
...@@ -89,9 +89,9 @@ class BytesLiteral(_bytes): ...@@ -89,9 +89,9 @@ class BytesLiteral(_bytes):
def utf8encode(self): def utf8encode(self):
assert False, "this is not a unicode string: %r" % self assert False, "this is not a unicode string: %r" % self
def as_unicode(self): def __str__(self):
"""Returns a Unicode sequence that matches the byte sequence """Fake-decode the byte string to unicode to support %
of this literal. formatting of unicode strings.
""" """
return self.decode('ISO-8859-1') 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