# HG changeset patch # User cmlenz # Date 1197407838 0 # Node ID 077c9142dca0c8e3e2f68a582f4ff33164f7b92e # Parent 9729855cacf49c1b109089df1a220e592598429a Fix case where attributes weren't properly wrapped in an `Attrs` instance if one or more of them were translated by the I18n filter, potentially breaking things further down the chain. Closes #162. diff --git a/genshi/filters/i18n.py b/genshi/filters/i18n.py --- a/genshi/filters/i18n.py +++ b/genshi/filters/i18n.py @@ -174,7 +174,7 @@ changed = True new_attrs.append((name, value)) if changed: - attrs = new_attrs + attrs = Attrs(new_attrs) if msgbuf: msgbuf.append(kind, data, pos) diff --git a/genshi/filters/tests/i18n.py b/genshi/filters/tests/i18n.py --- a/genshi/filters/tests/i18n.py +++ b/genshi/filters/tests/i18n.py @@ -15,12 +15,26 @@ from StringIO import StringIO import unittest +from genshi.core import Attrs from genshi.template import MarkupTemplate from genshi.filters.i18n import Translator, extract +from genshi.input import HTML class TranslatorTestCase(unittest.TestCase): + def test_translate_included_attribute_text(self): + """ + Verify that translated attributes end up in a proper `Attrs` instance. + """ + html = HTML(""" + + """) + translator = Translator(lambda s: u"Voh") + stream = list(html.filter(translator)) + kind, data, pos = stream[2] + assert isinstance(data[1], Attrs) + def test_extract_without_text(self): tmpl = MarkupTemplate("""

Foo