You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-python/genshi/files/genshi-0.7-issue566.patch

58 lines
2.2 KiB

From fafbc4296902b2259c23d2ce55996b0127726b4f Mon Sep 17 00:00:00 2001
From: SVN-Git Migration <python-modules-team@lists.alioth.debian.org>
Date: Thu, 8 Oct 2015 09:13:49 -0700
Subject: Fix an IndexError preventing Genshi for uploading attachments in
Trac for users with non-English language settings.
Origin: http://genshi.edgewall.org/changeset/1243?format=diff&new=1243
Bug: http://genshi.edgewall.org/ticket/566
Patch-Name: issue566.patch
---
genshi/filters/i18n.py | 8 +++++++-
genshi/filters/tests/i18n.py | 12 ++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/genshi/filters/i18n.py b/genshi/filters/i18n.py
index dfb52b8..8f2d25c 100644
--- a/genshi/filters/i18n.py
+++ b/genshi/filters/i18n.py
@@ -1048,7 +1048,13 @@ class MessageBuffer(object):
while parts:
order, string = parts.pop(0)
- events = self.events[order].pop(0)
+ events = self.events[order]
+ if events:
+ events = events.pop(0)
+ else:
+ # create a dummy empty text event so any remaining
+ # part of the translation can be processed.
+ events = [(TEXT, "", (None, -1, -1))]
parts_counter[order].pop()
for event in events:
diff --git a/genshi/filters/tests/i18n.py b/genshi/filters/tests/i18n.py
index 212d5f6..b36a30b 100644
--- a/genshi/filters/tests/i18n.py
+++ b/genshi/filters/tests/i18n.py
@@ -928,6 +928,18 @@ class MsgDirectiveTestCase(unittest.TestCase):
"""</p></html>""",
tmpl.generate(first="FIRST", second="SECOND").render())
+ def test_translate_i18n_msg_ticket_404_regression(self):
+ tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/"
+ xmlns:i18n="http://genshi.edgewall.org/i18n">
+ <h1 i18n:msg="name">text <a>$name</a></h1>
+ </html>""")
+ gettext = lambda s: u'head [1:%(name)s] tail'
+ translator = Translator(gettext)
+ translator.setup(tmpl)
+ self.assertEqual("""<html>
+ <h1>head <a>NAME</a> tail</h1>
+ </html>""", tmpl.generate(name='NAME').render())
+
class ChooseDirectiveTestCase(unittest.TestCase):